Skip to content

Instantly share code, notes, and snippets.

@seb86
Created June 20, 2017 13:57
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 seb86/1f2caec6988389c6857c1027d76555f5 to your computer and use it in GitHub Desktop.
Save seb86/1f2caec6988389c6857c1027d76555f5 to your computer and use it in GitHub Desktop.
My Git Aliases
[alias]
# Creates a new branch on your local machine and switches into this branch.
newbie = "!git checkout -b $(git branch-name)"
# Push the current branch to the remote "origin", and set it to track
# the upstream branch
publish = "!git push -u origin $(git branch-name)"
# Delete the remote version of the current branch
unpublish = "!git push origin :$(git branch-name)"
# Deletes a local branch on your filesystem.
db = "!git branch -d $(git branch-name)"
# Forces the deletion of a local branch on your filesystem.
db-f = "!git branch -D $(git branch-name)"
# Undo a commit
undo-commit = "reset --soft HEAD~1"
# Reset
unstage = "reset HEAD"
# Last log
lastlog = "log -1 HEAD"
# Show files ignored by git:
ignored = "ls-files -o -i --exclude-standard"
# Creates a local branch pr/branch-name from the GitHub upstream(if it exists) or origin remote and checks it out.
pr = "!f() { git fetch -fu ${2:-$(git remote |grep ^upstream || echo origin)} refs/pull/$1/head:pr/$1 && git checkout pr/$1; }; f"
# Creates a local branch pr/branch-name from some remote and checks it out.
pr-clean = "!git for-each-ref refs/heads/pr/* --format='%(refname)' | while read ref ; do branch=${ref#refs/heads/} ; git branch -D $branch ; done"
# Save all work into a "FIRE" branch incase of emergency.
fire = "!git add -A && git commit -m 'FIRE FIRE FIRE' && git push origin fire-branch"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment