Skip to content

Instantly share code, notes, and snippets.

@AvnerCohen
Last active January 9, 2016 21:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save AvnerCohen/a25a69df4e13f469c4ee to your computer and use it in GitHub Desktop.
Save AvnerCohen/a25a69df4e13f469c4ee to your computer and use it in GitHub Desktop.
Random Git aliases and commands to
# Command: GLOG
# Description: alias that creates a nice and easy on eye history log with graph indication of merge commits and branches
git config --global alias.glog "\!git log --graph --pretty=format:'%Cred%h%Creset %an: %s - %Creset %C(yellow)%d%Creset %Cgreen(%cr)%Creset' --abbrev-commit --date=relative ; true"
# Run:
git glog
# Command: LASTWORKS
# Description: Lists the last 10 branches you worked on
git config --global alias.lastworks "for-each-ref --count=10 --sort=-committerdate refs/heads/"
# Run:
git lastworks
# Command: Shortcuts
# Description: aliases for common commands to save on keystorkes
git config --global alias.co checkout
git config --global alias.pl "pull -r"
git config --global alias.st status
# Run:
git co ..
#Command: "Sorted Tags"
# Description: listing tas is ordered by name, which does not always makes sense, `stags` displays the tags sorted by creation date
git config --global alias.stags "\!git for-each-ref --format='%(*committerdate:raw)%(committerdate:raw) %(refname) %(*objectname) %(objectname)' refs/tags | sort -n | cut -d'/' -f 3 | cut -d' ' -f 1"
# Run:
git stags
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment