Last active
December 21, 2016 22:30
-
-
Save jasonrobot/2dca6bce66c16b401634938186aad1f1 to your computer and use it in GitHub Desktop.
Cool git commands (some shell in there too). Alias these to stuff in your shell if you want to use them quickly.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#deletes all branches that have been merged into master (except your current branch) (substitute "master" for whatever branch you want to clean against) | |
git branch --merged master | grep -v "\*" | xargs -n 1 git branch -d | |
#you can leave off the last command to just list them |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Adds the current branch you're on to your prompt (put this in your .bashrc file) | |
#be sure to do `source ~/.bashrc` to load it into your current session | |
parse_git_branch() { | |
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/(\1)/' | |
} | |
if [ "$color_prompt" = yes ]; then | |
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[01;31m\]$(parse_git_branch)\[\033[00m\]\$ ' | |
else | |
PS1='${debian_chroot:+($debian_chroot)}\u@\h:\w$(parse_git_branch)\$ ' | |
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Shows the branches you've most recently committed on, and how old they are (wow!) | |
#(you can change out the arg to tail to show as many lines as you want, or remove the call to tail altogether) | |
git for-each-ref --sort=committerdate refs/heads/ --format='%(HEAD) %(color:yellow)%(refname:short)%(color:reset) - %(color:red)%(objectname:short)%(color:reset) - %(contents:subject) - %(authorname) (%(color:green)%(committerdate:relative)%(color:reset))' | tail -n 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment