Skip to content

Instantly share code, notes, and snippets.

@elijahmurray
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save elijahmurray/634999b9cd55ba51e57f to your computer and use it in GitHub Desktop.
Save elijahmurray/634999b9cd55ba51e57f to your computer and use it in GitHub Desktop.
Useful git commands. Used a lot, forgotten just as much.
# reverse uncommitted changes
git clean -fd
# file names of changed files between master branch and your branch
git diff --name-status master..<yourbranch>
# push nonmaster branch to master branch. Optional -f flag to force it
git push [remote-name] [pushed-branch-name]:master
#rename current branch
git branch -m <newname>
#clear unstaged changes
git checkout -- .
#alias `checkout` to be `git co`
git config --global alias.co checkout
# ~/.bash_aliases
# other aliases
alias gst='git status'
alias gl='git pull'
alias gp='git push'
alias gd='git diff | mate'
alias gau='git add --update'
alias gc='git commit -v'
alias gca='git commit -v -a'
alias gb='git branch'
alias gba='git branch -a'
alias gco='git checkout'
alias gcob='git checkout -b'
alias gcot='git checkout -t'
# http://stackoverflow.com/questions/5807137/git-how-to-revert-uncommitted-changes-including-files-and-folders
# http://stackoverflow.com/questions/822811/showing-which-files-have-changed-between-git-branches
# http://stackoverflow.com/questions/14593538/make-heroku-run-non-master-git-branch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment