Git & GitHub Versus Other Version Control Systems • How to Use GitHub • Git -- The Basic Idiom • Git – Branches • Collaborating with Others -- Break -- • Setup GitHub Account • Setup Git on Your Computer • Lab Time • Wrap Up
realised it was a mistake and wanted to go back? • Lost code or had a backup that was too old? • Wanted to see the difference between two versions of your code? • Wanted to prove that a particular change broke or fixed some piece of code? • Wanted to experiment with a new feature without interfering with working code? http://stackoverflow.com/questions/1408450/why-should-i-use-version-control
security of having your work backed up • If you work with documents that change a lot or have multiple versions • If you work on a team project • If you apply for engineering/developer positions
• Bazaar Centralized • Subversion (SVN) • Concurrent Versions System (CVS) Remote Repository Hosting Services • GitHub • BitBucket • Your Own Server • Lots of other services!
Yeah, it doesn’t cut you any slack, but the tradeoff is that you get complete control • Everybody can see my stuff on GitHub. ◦ True, but you get to participate in a development community and are on your way to contributing to an open source project.
feature set available • You have a built in help function called the MAN page • If you are working with someone else, you won’t need to learn their client
I’ll be using sublime text to manage files ◦ http://www.sublimetext.com/2 • I’ll be using a bash terminal most of the time • I’ll show you ohmyzsh -- mac only :( ◦ https://github.com/robbyrussell/oh-my-zsh ◦ http://zsh-nt.sourceforge.net/ (windows?)
am deliberately not providing instructions here because GitHub changes its interface all the time. My instructions would quickly become outdated. Google is your friend :)
what others have done ◦ resolve merge conflicts early • git add <filename> ◦ let me bundle some work together • git commit -m “my comment” ◦ let me make a note about that bundle ◦ -m -- that’s a flag that says use no editor, use the string ◦ MAN page • git push ◦ send it up to the hosting service
am saving” ◦ My current work is not ready to be committed but I want to interact with the remote repo • git stash pop ◦ apply the last stashed change • git stash list ◦ show me all stashed changes
merge conflicts ◦ makes it easier to have a fine-grained timeline to play with ◦ helps with good coding practice -- write a method, write some tests, commit
on an aspect of a project without disrupting the work of others. • Gives you an easy way to have two parallel streams of work until you are ready to settle on one solution. • Lets you mix-and-match features from each branch. • Branches are often used for development in a professional environment.
branch • See local and remote branches ◦ git branch -a • Get a remote branch onto your local machine ◦ git checkout --track origin/<branch name> • Cut a new branch ◦ Make local branch ▪ git branch <branch name> ◦ Make remote branch ▪ git push -u origin <branch name> • Switch to a branch ◦ git checkout <branch name>
from branch to master: git checkout master git merge <branch name> It will interleave the commit history from branch with the commit history from master -- so it becomes a complete timeline!
branch. It’s harder to mix-and-match code ◦ git’s squash feature (git rebase -i <SHA/Commit ID from log>) lets you bundle commits together on branch, then you can git cherry-pick it to master http://stackoverflow.com/questions/5189560/how-can-i-squash-my-last-x-commits-together-using-git
contributing to open source projects ◦ using code created by others ◦ http://xkcdgraphs.com/ • Shared Repo ◦ How a professional office would likely use git ◦ Git Workflow
Clone -- a copy that exists in your GitHub account can be used submit pull requests/submit changes without a relationship to the project. Clone/ Shared Repo -- a copy that does not exist in your GitHub account and cannot change the remote repo unless the cloner is added as a collaborator on the project.
and other VCS • You know about GitHub and other hosting services • You have git and GitHub ready to go! • You know the basic idiom • You know some advanced ideas like branches and git workflow • You know how to call the MAN page • You have a git cheat sheet
http://www.ndpsoftware.com/git-cheatsheet.html • Continue with Githug ◦ https://rubygems.org/gems/githug • A great in-depth guide to git, also a book ◦ http://git-scm.com/book • The original git and GitHub GDI class slides ◦ http://teach.github.com/presentations/git-foundations.html • More on git workflow ◦ https://www.atlassian.com/git/workflows#!workflow-gitflow • Student/Educator? -- you may need a private account ◦ https://github.com/edu • More silly Ryan Gosling programming jokes ◦ http://programmerryangosling.tumblr.com/