Skip to content

Instantly share code, notes, and snippets.

@krzysu
Last active November 2, 2017 09:54
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 krzysu/fee862390f18a71a1c73ecc2d6c1eed1 to your computer and use it in GitHub Desktop.
Save krzysu/fee862390f18a71a1c73ecc2d6c1eed1 to your computer and use it in GitHub Desktop.
git advanced commands
# for local branches
git branch -avv | grep "release-2014" | awk '{ print $1 }' | xargs -n 1 git branch -D
# by branch name pattern
git branch -avv | grep "release-2014" | awk '{ gsub(/remotes\/origin\//, ""); print $1 }' | xargs -n 1 git push origin --delete
# merged to master
git branch -a --merged | egrep -v "(^\*|master|dev)" | awk '{ gsub(/remotes\/origin\//, ""); print $1 }' | xargs -n 1 git push origin --delete
# by commit date
git branch -a --sort=committerdate | head -n 20 | awk '{ gsub(/remotes\/origin\//, ""); print $1 }'
# commits in certain dates by certain people
git log --after="2017-10-25 00:00" --before="2017-10-27 00:00" --pretty=format:'%h%x09%an%x09%ad%x09%s' | grep -e 'Kris' -e 'Olexiy' -e 'Akbar'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment