我做了3个'git承诺‘,但我没有做'git推动’。
1. commit 1
2. commit 2
touches fileA
touches fileB
touches fileC
3. commit 3所以我怎么能
发布于 2009-08-29 00:49:24
这应该是可行的:
1. git rebase -i HEAD~2
2. in your editor, select the following:
edit 9b86592 commit 2
pick f3907cb commit 3
3. at this point roll back the changes you made in fileB, for example with
`git checkout <version_you_want>` or by manually editing the file
4. make the changes in fileC you want to be part of commit 2
5. `git add fileB fileC`
6. `git commit --amend`
7. `git rebase --continue`当git尝试应用提交3时,可能需要解决合并问题。在解决这些问题后,再次运行git rebase --continue。
发布于 2009-08-29 00:27:46
使用git rebase -i HEAD~2并编辑第二次提交。
发布于 2009-08-29 07:30:42
假设你在树枝上,拥有一棵干净的树:
# checkout incorrect commit
git checkout <sha1_of_commit2>
# revert the changes to fileB by checking out the parent version
git checkout HEAD^ -- fileB
# make an amended commit
git commit --amend
# go back to master
git checkout master
# transplant the changes since the bad commit onto the amended commit
git rebase --onto HEAD@{1} <sha1_of_commit2>https://stackoverflow.com/questions/1349998
复制相似问题