Skip to content

Instantly share code, notes, and snippets.

@amoroz
Last active July 18, 2016 16:29
Show Gist options
  • Save amoroz/9230970 to your computer and use it in GitHub Desktop.
Save amoroz/9230970 to your computer and use it in GitHub Desktop.
Git snippets
### Git snippets
== Synchronize local branch list with remote ==
git fetch origin -p
== Changing author info in history ==
If you need to modify the author info in your repository's history, you can do the following:
git filter-branch --commit-filter '
if [ "$GIT_COMMITTER_NAME" = "<Old Name>" ];
then
GIT_COMMITTER_NAME="<New Name>";
GIT_AUTHOR_NAME="<New Name>";
GIT_COMMITTER_EMAIL="<New Email>";
GIT_AUTHOR_EMAIL="<New Email>";
git commit-tree "$@";
else
git commit-tree "$@";
fi' HEAD
== Removing a file from all revisions ==
git filter-branch --index-filter 'git rm --cached --ignore-unmatch <file>' HEAD
== Overwriting (reset) a local branch with remote branch ==
git fetch origin
git reset --hard origin/master
== Making git "forget" about a file that was tracked but is now in .gitignore ==
git update-index --assume-unchanged <file>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment