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

后端 未结 12 913
时光取名叫无心
时光取名叫无心 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:50

    You should probably clone your repository first.
    
    Remove your file from all branches history:
    git filter-branch --tree-filter 'rm -f filename.orig' -- --all
    
    Remove your file just from the current branch:
    git filter-branch --tree-filter 'rm -f filename.orig' -- --HEAD    
    
    Lastly you should run to remove empty commits:
    git filter-branch -f --prune-empty -- --all
    

提交回复
热议问题