我做了3'git commit',但我没有做过'git push'.
1. commit 1
2. commit 2
touches fileA
touches fileB
touches fileC
3. commit 3
Run Code Online (Sandbox Code Playgroud)
那我该怎么办?
这应该工作:
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`
Run Code Online (Sandbox Code Playgroud)
如果git尝试应用提交时存在冲突,则可能需要解决合并问题.解决后git rebase --continue再次运行.