Last active
July 18, 2016 16:29
-
-
Save amoroz/9230970 to your computer and use it in GitHub Desktop.
Git snippets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 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