Git cheatsheet

COMMAND DESCRIPTION
git config --global user.name "Your Name" Sets your git name globally. Remove the "--global" flag to set for this git repository only.
git config --global user.email "you@email.com" Sets your git email address globally. Remove the "--global" flag to set for this git repository only.
git config --global core.editor "subl -n -w" Sets your git default editor. See this GitHub article for information on editors.
git init Initialises a git repository in your current directory.
git status Print the status of your git repository.
git add . Adds all untracked or modified files to the staging area.
git add filename.txt Adds only the named file to the staging area.
git commit Commits (saves a snapshot version of) any files in the staging area. Takes you to a text editor to save a commit message.
git commit -m "your message" Commits any files in the staging area with a commit message.
git log Shows all commits of the current repository.
git log -n Shows the most recent n commits.
git log --pretty=oneline --abbrev-commit Shows all commits in an easy to read format.
git diff Displays the difference between the current working directory and the last commit.
git branch Displays all available branches with an asterix next to the current branch.
git branch feature Creates a new branch called 'feature'.
git checkout feature Switches git HEAD to point at the feature branch.
git merge feature Merges changes from the feature branch into the current branch.
git branch -d feature Deletes the feature branch.
git remote REMOTE_REP * coming soon with next git article *
git clone REMOTE_REP * coming soon with next git article *
git push * coming soon with next git article *
git pull * coming soon with next git article *
git stash * coming soon with next git article *
git rm * coming soon with next git article *
git rebase * coming soon with next git article *