Removing history from git - git command fails

前端 未结 2 1552
梦毁少年i
梦毁少年i 2021-01-02 04:56

Im trying to purge a projects bin directory from Git history. I have already added \'bin\' to .gitignore and run $git rm --cached -r bin successfully. Now I hav

相关标签:
2条回答
  • 2021-01-02 05:32

    Okay so all I needed to do was add the -r to the rm command part (as below). I guess this is because bin is a directory rather than a file, so it must be removed recursively as otherwise the files it contains (or the information about them) would be orphaned.

    $ git filter-branch --force --index-filter \
      'git rm --cached -r --ignore-unmatch bin' \
      --prune-empty --tag-name-filter cat -- --all
    

    I followed this with the below to push the changes to the remote repo on github

    $ git push origin master --force
    
    0 讨论(0)
  • 2021-01-02 05:41

    The only place it makes sense is after the git rm. I have not tried it myself but I think that should work?

    $ git filter-branch --force --index-filter \
      'git rm -r --cached --ignore-unmatch bin' \
      --prune-empty --tag-name-filter cat -- --all
    
    0 讨论(0)
提交回复
热议问题