Skip to content

Instantly share code, notes, and snippets.

@akesson
Last active April 4, 2017 09:23
Show Gist options
  • Save akesson/b52778f665dd4019fe41e8a7712d972e to your computer and use it in GitHub Desktop.
Save akesson/b52778f665dd4019fe41e8a7712d972e to your computer and use it in GitHub Desktop.
Useful git aliases
[alias]
# delete all local tags and then fetch the ones on the server
cleantags = !git tag -l | xargs git tag -d && git fetch -t
# adds and pushes a single tag
addtag = "!f() { git tag $1; git push origin $1; }; f"
# removes all tags matching input on remote only. git removetags string_in_tag
removetags = "!f() { git tag -l | grep $1 | xargs git push --delete origin; echo 'Deleted tags remotely only. If all ok, do a cleantags to remove them locally as well or if NOK use pushtags to re-push them to remote'; }; f"
# push all local tags to server
pushtags = push origin --tags
# find the sha and branch(es) of a tag
findtag = "!f() { SHA=`git log -1 $1 --format="%h"` || exit 1; echo "SHA: $SHA"; echo "Branches:"; git branch --contains $SHA; }; f"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment