Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- git rebase -i -p <some HEAD before all of your bad commits>
- git rebase --continue
- git filter-branch -f --env-filter "GIT_AUTHOR_NAME='Newname'; GIT_AUTHOR_EMAIL='new@email'; GIT_COMMITTER_NAME='Newname'; GIT_COMMITTER_EMAIL='new@email';" HEAD
- git config --global user.name "you name"
- git config --global user.email you@domain.com
- git commit --amend --reset-author
- git rebase -i HEAD^^^^^^ # as required
- pick abcd Someone else's commit
- pick defg my bad commit 1
- pick 1234 my bad commit 2
- pick abcd Someone else's commit
- pick defg my bad commit 1
- exec git commit --amend --author="New Author Name <email@address.com>" -C HEAD
- pick 1234 my bad commit 2
- exec git commit --amend --author="New Author Name <email@address.com>" -C HEAD
- git change-commits GIT_AUTHOR_NAME "old name" "new name"
- git change-commits GIT_AUTHOR_EMAIL "old@email.com" "new@email.com" HEAD~10..HEAD
- change-commits = "!f() { VAR=$1; OLD=$2; NEW=$3; shift 3; git filter-branch --env-filter "if [[ \"$`echo $VAR`\" = '$OLD' ]]; then export $VAR='$NEW'; fi" $@; }; f "
- john=John Doe <john.doe@hotmail.com>
- jill=Jill Doe <jill.doe@hotmail.com>
- Name you want <email you want> Name you don't want <email you don't want>
- $ git rebase --onto origin/master origin/master@{1} master
- $ git log --author=user@wrong.email --all
- $ git cat-file -p <ID of wrong commit> |
- sed -e 's/user@wrong.email/user@example.com/g' > tmp.txt
- $ git hash-object -t commit -w tmp.txt
- <ID of corrected commit>
- $ git replace <ID of wrong commit> <ID of corrected commit>
- $ git replace -l
- $ git log --author=user@wrong.email --all
- git config user.name <good name>
- git config user.email <good email>
- git reset HEAD^
- git stash
- git reset HEAD^
- git commit -a
- git stash pop
- git commit -a
- pick a07cb86 Project tile template with full details and styling
- x git commit --amend --reset-author -Chead
- git config user.email my_other_email@example.com
- git commit --amend
- #!/bin/sh
- REPO_URL=ssh://path/to/your.git
- REPO_DIR=rewrite.tmp
- # Clone the repository
- git clone ${REPO_URL} ${REPO_DIR}
- # Change to the cloned repository
- cd ${REPO_DIR}
- # Checkout all the remote branches as local tracking branches
- git branch --list -r origin/* | cut -c10- | xargs -n1 git checkout
- # Rewrite the history, use a system that will preseve the eol (or lack of in commit messages) - preferably Linux not OSX
- git filter-branch --env-filter '
- OLD_EMAIL="me@something.com"
- CORRECT_NAME="New Me"
- if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
- then
- export GIT_COMMITTER_NAME="$CORRECT_NAME"
- fi
- if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
- then
- export GIT_AUTHOR_NAME="$CORRECT_NAME"
- fi
- ' --tag-name-filter cat -- --branches --tags
- # Force push the rewritten branches + tags to the remote
- git push -f
- # Remove all knowledge that we did something
- rm -rf ${REPO_DIR}
- # Tell your colleagues to `git pull --rebase` on all their local remote tracking branches
- $ git changemail -a old@email.com -n newname -m new@email.com
- $ git changemail -b old@email.com -n newname -m new@email.com -- -f <branch> <branch2>
- $ git changemail --show-both
- git rebase -i YOUR_FIRTS_COMMIT_SHA^
- while true; do git commit --amend --author="Name Surname <email@example.com>" --no-edit && git rebase --continue; done
- $ git checkout <commit-hash> # checkout to the commit need to modify
- $ git commit --amend --author "name <author@email.com>" # change the author name and email
- $ git replace <old-commit-hash> <new-commit-hash> # replace the old commit by new one
- $ git filter-branch -- --all # rewrite all futures commits based on the replacement
- $ git replace -d <old-commit-hash> # remove the replacement for cleanliness
- $ git push -f origin HEAD # force push
- $ git rebase -i <commit-hash> # go to last good commit
- # Editor would open, replace 'pick' with 'edit' before the commit want to change author
- $ git commit --amend --author="author name <author@email.com>" # change the author name & email
- # Editor would open, save and exit
- $ git rebase --continue # finish the rebase
- #!/bin/sh
- PWD=`pwd`
- if [[ $PWD == *"Ippon"* ]] # 1)
- then
- EMAIL=$(git config user.email)
- if [[ $EMAIL == *"Work"* ]] # 2)
- then
- echo "";
- else
- echo "Email not configured to your Work email in the Work directory.";
- git config user.email "youremail@youremail.com"
- echo "Git email configuration has now been changed to "$(git config user$
- echo "nPlease run your command again..."
- echo ''
- exit 1
- fi;
- elif [[ $PWD == *"Personal"* ]]
- then
- EMAIL=$(git config user.email)
- if [[ $EMAIL == "youremail@youremail.com" ]]
- then
- echo "";
- else
- echo "Email is not configured to your personal account in the Personal di$
- git config user.email "youremail@youremail.com"
- echo "Git email configuration has now been changed to "$(git config user$
- echo "nPlease run your command again..."
- echo ''
- exit 1;
- fi;
- fi;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement