I have local branch. I write new files, change some other and delete one file by mistake. Commit.
Again write code (new/change files). Commit.
No push.
I want to remove deleting file in my first commit.
I do not want amend second commit to restore deleted file.
Can anybody help me? I have no ideas.
My solution:
git rebase -i HEAD~2
[Change for first commit 'pick' to 'edit']
git reset HEAD^
[Revert deleted file]
[Add other files and commit]
git rebase --continue
git checkout <id-of-commit1>~1 path/to/the/deleted/file
git commit --fixup <id-of-commit1>
git rebase -i --autosquash
[it opens editor, check that the rebase plan is correct, exit the editor to proceed]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.