How can I delete a file from a Git repository?

后端 未结 24 2247
無奈伤痛
無奈伤痛 2020-11-22 13:41

I have added a file named \"file1.txt\" to a Git repository. After that, I committed it, added a couple of directories called dir1 and dir2

24条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-22 14:03

    go to your project dir and type:

    git filter-branch --tree-filter 'rm -f ' HEAD
    

    after that push --force for delete file from all commits.

    git push origin --force --all
    

提交回复
热议问题