List of commands for a quick recap:
Initializing a repository in current directory
git init
start version-controlling existing files
git add *.java
git add
Commit message inline with the commit command
git commit -m "comment"
Checking the Status of Your Files
git status
Ignoring Files
.gitignore
To see what you’ve changed but not yet staged
git diff
diff between two branches
git diff..<name>
diff from common ancestor
git diff...<name>
compare your staged changes to your last commit
git diff --cached
compare working directory to your last commit
git diff HEAD
compare your current working directory to the state in another branch
git diff <branch>
limit the comparison to a specific file or subdirectory by adding a path limiter
git diff -- <file/folder>
output the files that have changed along with a little text graph depicting how many lines changed in each file
git diff --stat
Skipping the Staging Area
git commit -a -m "comment"
Removing Files
git rm <file>
keep the file on your hard drive but not have Git track it anymore
git rm --cached <file>
Moving Files
git mv <old> <new> (equivalent to mv <old> <new>, git rm <old>, git add <new>
Cloning an Existing Repository
git clone <url>
Viewing the Commit History
git log
diff introduced in each commit
git log -p
limit the output to only the last two entries
git log -p -2
abbreviated stats for each commit
git log --stat
prints each commit on a single line
git log --pretty=short/full/fuller/oneline
adds a nice little ASCII graph showing your branch and merge history
git log --graph
Changing Your Last Commit
git commit --amend
Unstaging a Staged File
git reset HEAD <file>
Unmodifying a Modified File
git checkout -- <file>
Create a branch
git branch <name>
Switch to branch
git checkout <name>
create a branch and switch to it at the same time
git checkout -b <name>
merge back into master branch
git checkout master
git merge <branch>
Delete the branch
git branch -d <name>
graphical tool to resolve merge conflicts
git mergetool
listing of your current branches
git branch
To see the last commit on each branch
git branch -v
branches that are or are not yet merged into the current branch
git branch --merged
git branch --no-merged