GitHub Talk - Cody Carnachan

  • 173 views
Uploaded on

A basic introduction to Git and GitHub + a bit on workflow.

A basic introduction to Git and GitHub + a bit on workflow.

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
173
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
0
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. GITHUB& A BIT ON WORKFLOWThursday, 30 May 13
  • 2. WHAT IS SCM?SOURCE CODE MANAGEMENT• Storing versions of files• Good backup• Important when working in teams• Points to revert back toThursday, 30 May 13
  • 3. SCM SYSTEMSSOME EXAMPLES• MercurialSUPER QUICK, LARGE DEV-TEAMS, SIMPLE• SubversionWIDEST ADOPTION, CHECKING OUT FILES, CENTRAL SERVER• GitGROWING QUICKLY, SUPER FAST, DELTA CHANGES, GITHUB, AWESOMEThursday, 30 May 13
  • 4. GIT VS GITHUB• Distributed source code managementsystem• Hosted solution to facilitate easycollaboration on Git repositoriesThursday, 30 May 13
  • 5. WHY GIT?• Distributed• Super-fast• Lightweight• Server-less• Personal preference• GitHubThursday, 30 May 13
  • 6. WHY GIT?• Distributed• Super-fast• Lightweight• Personal preference• GitHubThursday, 30 May 13
  • 7. WHY GIT?• Distributed• Super-fast• Lightweight• Personal preference• GitHubThursday, 30 May 13
  • 8. WHY GIT?• Distributed• Super-fast• Lightweight• Personal preference• GitHubThursday, 30 May 13
  • 9. WHY GIT?• Distributed• Super-fast• Lightweight• Personal preference• GitHubThursday, 30 May 13
  • 10. WHY GIT?• Distributed• Super-fast• Lightweight• Personal preference• GitHubThursday, 30 May 13
  • 11. GITHUB, GITHUB, GITHUBMORE ON THIS MAGICAL TOOL• Git repository hosting• Web tool suite• Collaborative development• Social coding (forking)Thursday, 30 May 13
  • 12. INSTALLING GITHANDS-ON #1MAC<3 - Easy as pieWINDOWSGood luckhttps://help.github.com/articles/set-up-gitThanks GitHub, let’s visit:Thursday, 30 May 13
  • 13. GIT WORKFLOW$ cd ~/Desktop/$ mkdir gitcd is the unix command for‘change directory’. ~/ isyour home directory.mkdir is the unix commandfor ‘make directory’. Thesame thing as creating anew folder.Thursday, 30 May 13
  • 14. GIT WORKFLOWgit init will turn the currentfolder into a git repository.Git will now monitor thisfolder and any files andsub-directories for changes$ cd ~/Desktop/$ mkdir git$ cd git$ git initThursday, 30 May 13
  • 15. GIT WORKFLOWgit status tells you thecurrent status of therepository (changed filesetc)Now: open up your texteditor and create a blanktxt file. Save it in the samedirectory as your git repo.$ git init$ git statusThursday, 30 May 13
  • 16. GIT WORKFLOWgit status will now tell youthere are untracked filesgit add [filename] is used toadd files to the stage for acommit$ git status$ git add hello.txtThursday, 30 May 13
  • 17. WOAH, SLOW DOWN!SOME GIT TERMINOLOGYSTAGEA SET OF “STAGED” CHANGES THAT WILL BE PART OF ACOMMITCOMMITA PERMANENT SNAPSHOT OFYOUR GIT REPOSITORY AT AGIVEN TIMEThursday, 30 May 13
  • 18. GIT WORKFLOWgit commit will create asnapshot of your repositorysaving all staged changesWe use the -m flagfollowed by a string todefine a commit message.Keep in mind that unstagedchanges won’t be saved.$ git status$ git add hello.txt$ git commit -m “Initial commit”Thursday, 30 May 13
  • 19. GIT WORKFLOWgit status will show nochanges1. Make a change tohello.txt2. Make a new file3. Commit JUST the newfile$ git status$ git add hello.txt$ git commit -m “Initial commit”$ git statusThursday, 30 May 13
  • 20. HOLD UP!What do you notice?Thursday, 30 May 13
  • 21. TEAM WORKFLOWUSING GIT & GITHUB• Role-oriented AND random editing of fileswithout fear of overwriting anyone else’s work• Branching off from the master (main) code base towork on individual features WITHOUT breakingthe whole site• Multiple backups of the code-base• Ability to revert to ANY previous version of a fileThursday, 30 May 13
  • 22. ‘ADVANCED’ TERMINOLOGYPUSHINGPUSHYOUR COMMITS TO THE UPSTREAM SERVER (GITHUB)PULLINGPULL DOWN THE LATEST COMMITS FROM THE UPSTREAM SERVER (GITHUB)MASTER BRANCHMASTER IS THE DEFAULT BRANCH INYOUR REPOSITORY.THIS IS THE MAIN CODE BASEAND SHOULD AT ALL TIMES CONTAIN DEPLOYABLE CODE.BRANCHINGCREATING ADDITIONAL BRANCHES OFF OF MASTER TO WORK ON INDIVIDUAL FEATURESThursday, 30 May 13
  • 23. PUSHING & PULLINGUSING AN UPSTREAM SERVER (GITHUB)• In your teams: push and pull as often aspossible• Before starting work on, always PULL• Try to use another communication tool (FB,Skype etc) to keep in touch when developingand tell eachother when you have madechanges.Thursday, 30 May 13
  • 24. OH SHIT!SOMEONE EFFED’ UP•You probably went to push some commitswithout pulling from GitHub and now you havesome screwed up, out of order repo.•Solving this problem can be a bitch so crossyour fingers and hope for the best.Thursday, 30 May 13
  • 25. OH SHIT!THE SOLUTION• Run git pull. Git will force you to mergethe changes but you will need to do thismanually.• Run git merge. Git will merge yourcommits with the upstream commits intoa new commit, then push.Thursday, 30 May 13
  • 26. BRANCHINGSOME GIT AWESOMENESS• Branching should be used when you want towork on a specific feature• Give your branches descriptive namesi.e. user-login or pretty-forms• Don’t try and make your branches allencompassing (keep them small and modular)Thursday, 30 May 13
  • 27. USING GITHUBHANDS-ON #2http://github.comGo to ^ and make an accountThursday, 30 May 13
  • 28. TEAM WORKFLOWBRANCHING, PULL REQUESTS & MERGING• Get in your teams• The technical lead should create a repository ontheir account then go to settings and invite theother members of your team as collaborators.• Everybody grab the URL found on the repo page:Thursday, 30 May 13
  • 29. BRANCHING$ cd ~/Desktop/$ git clone https://github.com/codycarnachan/mds.gitLet’s reset our directory toour Desktop.git clone is the commandfor cloning a repository.Make sure you put yourown URL in; you won’t beable to clone repositoriesthat you aren’t acollaborator on.Thursday, 30 May 13
  • 30. BRANCHING$ cd ~/Desktop/$ git clone https://github.com/codycarnachan/mds.git$ git checkout -b new-branch-namegit checkout -b[branchname] is thecommand for creating anew branch and switchingto it (or just switching if italready exists)Changes you make now willbe independent to themaster brachThursday, 30 May 13
  • 31. BRANCHING$ cd ~/Desktop/$ git clone https://github.com/codycarnachan/mds.git$ git checkout -b new-branch-nameCreate a file with sometext and then commit it.Note: There is a differentformat to push your newlocal branch to theupstream server:git push -u origin[branchname]Thursday, 30 May 13
  • 32. TEAM WORKFLOWBRANCHING, PULL REQUESTS & MERGING• You can checkout each others branches to testfeatures that might be in progress.• Once you have a branch with code that is ready toget merged into master. Go to the GitHub page >Branches > Click on the branch and then Click PullRequest• The Technical Lead should be responsible formerging pull requests to keep everything streamlined.Thursday, 30 May 13
  • 33. RECAP• git init• git clone• git add• git commit• git push• git pull• git status• git merge• git checkout• pull requestsThursday, 30 May 13
  • 34. FURTHER READING• A general guide to pushing/pullinghttp://tinyurl.com/c3yr2v• What to do when master is ahead of youhttp://tinyurl.com/nh9jt2t• Basic overview of branching and merginghttp://tinyurl.com/btwgu79• Setting up Git at homehttps://help.github.com/articles/set-up-gitThursday, 30 May 13
  • 35. THE END!ANY QUESTIONS? HIT ME UPThursday, 30 May 13