Skip to content

Instantly share code, notes, and snippets.

@pinge
Last active July 21, 2017 03:02
Show Gist options
  • Save pinge/7683250 to your computer and use it in GitHub Desktop.
Save pinge/7683250 to your computer and use it in GitHub Desktop.
git cheatsheet

change a specific author email address by rewriting history:

git filter-branch --env-filter '
  if [ $GIT_AUTHOR_EMAIL = current@email ]; then GIT_AUTHOR_EMAIL=updated@email; fi;
  export GIT_AUTHOR_EMAIL;
'

change commit author for specific commits:

interactive rebase from an earlier point in history than the specific commits

git rebase -i <earliercommit>

change 'pick' to 'edit' on the commits you want to modify

git commit --amend --author="Author Name <updated@email>"

resume rebase and repeat amend/continue for every selected commit

git rebase --continue

change commit message for specific commits:

git rebase -i <earliercommit>

change 'pick' to 'edit' on the commits you want to modify

git commit --amend

resume rebase and repeat amend/continue for every selected commit

git rebase --continue

remove all tags (local and remote):

git tag | xargs git tag -d
git ls-remote --tags origin | sed -E 's/.*refs\/tags\/(.*)/\1/' | xargs -i git push origin :refs/tags/{}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment