Skip to content

Instantly share code, notes, and snippets.

@jeremyolliver
Created February 26, 2009 01:33
Show Gist options
  • Save jeremyolliver/70582 to your computer and use it in GitHub Desktop.
Save jeremyolliver/70582 to your computer and use it in GitHub Desktop.
Git Command Reference
# Remote branch management
# 'checkout' locally a branch on the remote repo
git checkout -b <local name> origin/<remote name>
# Remove a branch both locally and remotely
git branch -d <branchname> # -d for when already merged to current branch. -D to force delete of un-merged branch anyway
git push origin :<branchname>
# commiting and pushing
git commit -a -m "Message"
git push origin <current_branch>
# Updating off server
git pull origin <remote_branch>
# amend last commit. Makes amendment, then run this command listing all files to amend.
git commit --amend <file1> <file2>
# Undo last commit.
git reset --soft HEAD^ # undoes one commit use ref HEAD^^ to go back two commits etc
# makes changes to files
git commit -a -c ORIG_HEAD
# Diff files
git format-patch master --stdout > your-patch-file.diff
# applying
git am < their-patch-file.diff
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment