Skip to content

Instantly share code, notes, and snippets.

@lewiseason
Last active August 29, 2015 14:21
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 lewiseason/626692b9d72f7593afd6 to your computer and use it in GitHub Desktop.
Save lewiseason/626692b9d72f7593afd6 to your computer and use it in GitHub Desktop.
Move Tags when Rewriting History
while (<>) {
chomp($_);
($old, $tag, $message) = split("\0", $_);
# Escape double quotes
$message =~s/"/\\"/g;
@matches = split("\n", `git log --all --oneline --grep="^$message\$"`);
$count = @matches;
if ($count == 1){
($new, $dummy) = split(' ', $matches[0], 2);
print "$tag\t${old}->${new}\n";
`git tag -a "$tag" $new -f -m "$message"`;
} else {
print "* Problem with $tag. Hash was $old, message was: $message\n";
}
}
while (<>) {
chomp($_);
($hash, $tag) = split(' ', $_);
($short, $message) = split(' ', `git log -1 --oneline $hash`, 2);
chomp($message);
print "$short\0$tag\0$message\n";
`git tag -d $tag`
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment