Advertisement
Guest User

Untitled

a guest
Apr 12th, 2017
1,623
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.96 KB | None | 0 0
  1. git rebase -i -p <some HEAD before all of your bad commits>
  2.  
  3. git rebase --continue
  4.  
  5. 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
  6.  
  7. git config --global user.name "you name"
  8. git config --global user.email you@domain.com
  9. git commit --amend --reset-author
  10.  
  11. git rebase -i HEAD^^^^^^ # as required
  12.  
  13. pick abcd Someone else's commit
  14. pick defg my bad commit 1
  15. pick 1234 my bad commit 2
  16.  
  17. pick abcd Someone else's commit
  18. pick defg my bad commit 1
  19. exec git commit --amend --author="New Author Name <email@address.com>" -C HEAD
  20. pick 1234 my bad commit 2
  21. exec git commit --amend --author="New Author Name <email@address.com>" -C HEAD
  22.  
  23. git change-commits GIT_AUTHOR_NAME "old name" "new name"
  24.  
  25. git change-commits GIT_AUTHOR_EMAIL "old@email.com" "new@email.com" HEAD~10..HEAD
  26.  
  27. 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 "
  28.  
  29. john=John Doe <john.doe@hotmail.com>
  30. jill=Jill Doe <jill.doe@hotmail.com>
  31.  
  32. Name you want <email you want> Name you don't want <email you don't want>
  33.  
  34. $ git rebase --onto origin/master origin/master@{1} master
  35.  
  36. $ git log --author=user@wrong.email --all
  37.  
  38. $ git cat-file -p <ID of wrong commit> |
  39. sed -e 's/user@wrong.email/user@example.com/g' > tmp.txt
  40. $ git hash-object -t commit -w tmp.txt
  41. <ID of corrected commit>
  42.  
  43. $ git replace <ID of wrong commit> <ID of corrected commit>
  44.  
  45. $ git replace -l
  46.  
  47. $ git log --author=user@wrong.email --all
  48.  
  49. git config user.name <good name>
  50. git config user.email <good email>
  51. git reset HEAD^
  52. git stash
  53. git reset HEAD^
  54. git commit -a
  55. git stash pop
  56. git commit -a
  57.  
  58. pick a07cb86 Project tile template with full details and styling
  59. x git commit --amend --reset-author -Chead
  60.  
  61. git config user.email my_other_email@example.com
  62. git commit --amend
  63.  
  64. #!/bin/sh
  65.  
  66. REPO_URL=ssh://path/to/your.git
  67. REPO_DIR=rewrite.tmp
  68.  
  69. # Clone the repository
  70. git clone ${REPO_URL} ${REPO_DIR}
  71.  
  72. # Change to the cloned repository
  73. cd ${REPO_DIR}
  74.  
  75. # Checkout all the remote branches as local tracking branches
  76. git branch --list -r origin/* | cut -c10- | xargs -n1 git checkout
  77.  
  78. # Rewrite the history, use a system that will preseve the eol (or lack of in commit messages) - preferably Linux not OSX
  79. git filter-branch --env-filter '
  80. OLD_EMAIL="me@something.com"
  81. CORRECT_NAME="New Me"
  82.  
  83. if [ "$GIT_COMMITTER_EMAIL" = "$OLD_EMAIL" ]
  84. then
  85. export GIT_COMMITTER_NAME="$CORRECT_NAME"
  86. fi
  87. if [ "$GIT_AUTHOR_EMAIL" = "$OLD_EMAIL" ]
  88. then
  89. export GIT_AUTHOR_NAME="$CORRECT_NAME"
  90. fi
  91. ' --tag-name-filter cat -- --branches --tags
  92.  
  93. # Force push the rewritten branches + tags to the remote
  94. git push -f
  95.  
  96. # Remove all knowledge that we did something
  97. rm -rf ${REPO_DIR}
  98.  
  99. # Tell your colleagues to `git pull --rebase` on all their local remote tracking branches
  100.  
  101. $ git changemail -a old@email.com -n newname -m new@email.com
  102.  
  103. $ git changemail -b old@email.com -n newname -m new@email.com -- -f <branch> <branch2>
  104.  
  105. $ git changemail --show-both
  106.  
  107. git rebase -i YOUR_FIRTS_COMMIT_SHA^
  108.  
  109. while true; do git commit --amend --author="Name Surname <email@example.com>" --no-edit && git rebase --continue; done
  110.  
  111. $ git checkout <commit-hash> # checkout to the commit need to modify
  112. $ git commit --amend --author "name <author@email.com>" # change the author name and email
  113.  
  114. $ git replace <old-commit-hash> <new-commit-hash> # replace the old commit by new one
  115. $ git filter-branch -- --all # rewrite all futures commits based on the replacement
  116.  
  117. $ git replace -d <old-commit-hash> # remove the replacement for cleanliness
  118. $ git push -f origin HEAD # force push
  119.  
  120. $ git rebase -i <commit-hash> # go to last good commit
  121.  
  122. # Editor would open, replace 'pick' with 'edit' before the commit want to change author
  123.  
  124. $ git commit --amend --author="author name <author@email.com>" # change the author name & email
  125.  
  126. # Editor would open, save and exit
  127. $ git rebase --continue # finish the rebase
  128.  
  129. #!/bin/sh
  130. PWD=`pwd`
  131. if [[ $PWD == *"Ippon"* ]] # 1)
  132. then
  133. EMAIL=$(git config user.email)
  134. if [[ $EMAIL == *"Work"* ]] # 2)
  135. then
  136. echo "";
  137. else
  138. echo "Email not configured to your Work email in the Work directory.";
  139. git config user.email "youremail@youremail.com"
  140. echo "Git email configuration has now been changed to "$(git config user$
  141. echo "nPlease run your command again..."
  142. echo ''
  143. exit 1
  144. fi;
  145. elif [[ $PWD == *"Personal"* ]]
  146. then
  147. EMAIL=$(git config user.email)
  148. if [[ $EMAIL == "youremail@youremail.com" ]]
  149. then
  150. echo "";
  151. else
  152. echo "Email is not configured to your personal account in the Personal di$
  153. git config user.email "youremail@youremail.com"
  154. echo "Git email configuration has now been changed to "$(git config user$
  155. echo "nPlease run your command again..."
  156. echo ''
  157. exit 1;
  158. fi;
  159. fi;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement