Skip to content

Instantly share code, notes, and snippets.

@vivekragunathan
Last active August 28, 2018 23:53
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 vivekragunathan/1c692d6c8350388bdd276e9e6e13a211 to your computer and use it in GitHub Desktop.
Save vivekragunathan/1c692d6c8350388bdd276e9e6e13a211 to your computer and use it in GitHub Desktop.
Handy git commands

Get Commits Between Dates

git log --after="2018-06-30" --before="2018-07-03" --oneline

Get {author}'s Branches

git for-each-ref --format=' %(authorname) %09 %(refname)' --sort=authorname | grep '{author}'

Get Commits Ordered by Commit Date Across Branches

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))'

Rename branch (Local and Remote)

git branch -m new-name # Use git branch -m old-name new-name if renaming from a different branch

git push origin :old-name new-name

git push origin -u new-name

Commit Stats (Ordered by most-committed 😂 author)

git shortlog -s -n
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment