Git is very simple. It's very powerful, but fundamentally very logical and very simple. If you try to learn everything you can do with git, then the information will flood your brain and drown you. That's true of any powerful tool like Photoshop and Unix.
But if you just want to use git to backup your code changes, develop new branches, and share your source, git is actually as straightforward as SVN. Avoid complex and dangerous commands like git-rebase. I've worked on large codebases with distributed teams and I've never needed anything more than basic commit, branch/merge, and push/pull. Git also has useful log, diff, and grep tools for quickly finding out information about your code.
Git Flow: Git for Humans
To use git without brain augmentation surgery, you should make a simple, consistent system for yourself with a handful of commands. Or just use my system.
You want to commit often, so it's good to create bash shortcuts so that you use git more often. The 2-letter shortcuts encourage you to commit more often and keep everyone's code up to date. You'll never be afraid of losing code.
Here's my main workflow, commit and push:
$ # make changes, fix bugs...
$ cm "fixed bug 214 in the UI"
$ ph
I'm constantly checking the status to see if I forgot to add files or commit something:
$ sl
# On branch master
nothing to commit (working directory clean)
If I'm branching, I create a branch, make my changes, and then merge.
$ ct -b newfeature
# make changes
$ ct master
$ me newfeature
And then I can push my changes and delete the branch.
$ ph
$ bh -d newfeature
You want to commit often, so always cm (git commit -a -m) and ph (git push) after even small changes. The 2-letter shortcuts encourage you to commit more often and keep everyone's code up to date.
The codes are easy to remember because they are consistent. The codes are always 2 letters, composed of precisely the first letter of the command and the last letter (including all of the options). By using the last letter of the command including options, the shortcut tricks your mind into thinking of the full command every time you type it. Normally, you forget commands with abbreviations of the first letters, but with my system you remember the whole command every time so you can still use git on other systems and other peoples' computers.
Git Flow Examples
Where is this variable myVar declared (git grep)?
$ gp myVar
How is my branch different from master (git diff --ignore-space-change)?
$ de master
I forgot, did I commit all my changes, what files did I forget to add (git status -uall)?
$ sl
How do I make a new branch (git checkout -b)?
$ ct -b mybranch
How do I merge it back (git merge)?
$ #ensure you've committed all changes in your branch
$ ct master
$ me mybranch
How do I delete my branch after I've merged changes (git branch -d)?
$ bh -d mybranch
How do I pull and push my changes (git pull, git push)?
$ pl
$ ph
What changes were made recently (git log)?
$ lg
What branches exist and branch am I on (git branch)?
$ bh
What if I screwed up and want to remove all the code in my branch without merging (git branch -D, since caps are harder)?
$ bh -D mybranch
How do I make a new repository?
$ git init
I just added new files to my code, how do I add them to my git repository?
$ ad .
Below are my bash aliases. Add these to your ~/.bashrc file so that you can use these shortcuts too:
alias ad='git add'
alias pl='git pull'
alias ph='git push'
alias cm='git commit -a -m'
alias sl='git status -uall'
alias lg='git log'
alias gp='git grep'
alias de='git diff --ignore-space-change'
alias me='git merge'
alias bh='git branch'
alias ct='git checkout'