How do you fix a bad merge, and replay your good commits onto a fixed merge?

后端 未结 12 914
时光取名叫无心
时光取名叫无心 2020-11-21 10:25

I accidentally committed an unwanted file (filename.orig while resolving a merge) to my repository several commits ago, without me noticing it until now. I want

12条回答
  •  长情又很酷
    2020-11-21 10:46

    Just to add that to Charles Bailey's solution, I just used a git rebase -i to remove unwanted files from an earlier commit and it worked like a charm. The steps:

    # Pick your commit with 'e'
    $ git rebase -i
    
    # Perform as many removes as necessary
    $ git rm project/code/file.txt
    
    # amend the commit
    $ git commit --amend
    
    # continue with rebase
    $ git rebase --continue
    

提交回复
热议问题