How to modify specific word in existing commit?
This question already has an answer here:
The crux of the question (emphasis added)
i need to edit 3rd commit without producing additional commit . is there a way to do?
No, it is not possible. A commit cannot be changed in any way. The commit's ID is calculated in such a way that any change to the commit's content would change the ID of that commit and every commit descended from it, and if you "change" a commit's ID that really means you're creating a new commit (albeit one that may be very similar to the original).
The possible choices are:
1) Fix the problem in the next commit, and accept that the history will always contain the incorrect words in these previous commits
2) Rewrite the history, requiring clean-up on all clones of the remote(s) to which you've already pushed the existing commits
try :
git rebase -i <sha or tag before the commit you wish to update>
this will open an editor where you will specify what you want to do then on commit 3 you can update commit
git commit --amend
then git rebase --continue
will restart the process of rebase. then you will use
git push -f
to update server side (be careful this has some draw back, mainly if other dev have pulled this branch)
I suggest that you 1st create a branch and practice this on a branch.
Also have a look at git doc on interactive rebase
链接地址: http://www.djcxy.com/p/23432.html上一篇: 学习Vim有什么好处?
下一篇: 如何修改现有提交中的特定单词?