Phil Lamond
If you want to hear it from the horse's mouth, watch Git by a git (Linus Torvalds who also created and maintains the Linux kernel project)
Or read the git manual page/tutorial
A vanilla project
git init
Inform git about who you are
git config --global user.name "BBC Developer"
git config --global user.email bbc.developer@bbc.co.uk
And set up fancy colours in your terminal
git config --global color.ui true
Get git to tell you what it thinks of your project
git status
Add the files you want under version control
git add file1 file2
Commit your added files
git commit
Or
git commit -m "My awesome code changes"
Or add and commit at the same time (catches all unversioned files)
git commit -a
Imagine there are two developers working on the same project
Where am I at now?
git status
Better get changes from the remote master
git pull
(combines git fetch
and git merge
)
Good, right those changes merged ok
Now commit and push my work
git status
git commit -a -m "These changes will get me kudos, man"
git push origin master
That pushed up alright.
Ruh oh... those changes were not cool, I forgot to write unit tests and I've b0rkened the app!
Should've made a branch coz I wasn't finished!
Quick, rewind! Ok, make a branch first
git branch coolfeature
Rewind the remote master back by one changeset (push) and switch to the new branch (with my bad changes preserved)
git reset --hard HEAD^
git checkout coolfeature
Push up the new branch
Now commit and push my work
git status
git commit -a -m "This will get me doughnuts and crisps, coz I now have unit tests"
git push origin coolfeature
git clone git://github.com/phillamond/mycoolrepo
Checks out and attaches your local working directory to the remote master
Killer feature: pull requests
Caveat: I've only covered a core subset of git commands and github.com usage
Git is popular in the software development industry because of its really rich feature set that sets it apart from other (older) VCS systems like Subversion and CVS. It is used in earnest by big players like Google and Facebook and it seems a welcome move that the BBC are adopting it.