Skip to content

Instantly share code, notes, and snippets.

@infinitewarp
Created June 6, 2016 19:13
Show Gist options
  • Save infinitewarp/4e3edf4563a028bd0efb9dce82338397 to your computer and use it in GitHub Desktop.
Save infinitewarp/4e3edf4563a028bd0efb9dce82338397 to your computer and use it in GitHub Desktop.
# This is Git's per-user configuration file.
[user]
name = TODO
email = TODO
[core]
autocrlf = input
[alias]
# I wish default logging was more useful.
glog = "log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n'' %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all"
# Mercurial has memorable commands like this.
# reset --soft will not update the working copy, preserving the committed change in it.
# reset --hard will update the working copy, causing you to lose everything from the commit.
rollback = "reset --soft HEAD~"
#####
# These aliases help clean up tags.
# see: http://stackoverflow.com/a/30383309
# Return date of tag. (To use in another alias)
tag-date = "!git show $1 | awk '{ if ($1 == \"Date:\") { print substr($0, index($0,$3)) }}' | tail -2 | head -1 #"
# Show tag message
tag-message = "!git show $1 | awk -v capture=0 '{ if(capture) message=message\"\\n\"$0}; BEGIN {message=\"\"}; { if ($1 == \"Date:\" && length(message)==0 ) {capture=1}; if ($1 == \"commit\" ) {capture=0} }; END { print message }' | sed '$ d' | cat -s #"
### Move tag. Use: git tagm <tagname> <newcommit>
tagm = "!GIT_TAG_MESSAGE=$(git tag-message $1) && GIT_COMMITTER_DATE=$(git tag-date $1) && git tag-message $1 && git tag -d $1 && git tag -a $1 $2 -m \"$GIT_TAG_MESSAGE\" #"
### Move pushed tag. Use: git tagmp <tagname> <newcommit>
tagmp = "!git tagm $1 $2 && git push --delete origin $1 && git push origin $1 #"
#####
[color]
ui = true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment