How to remove a file permanently in Git without getting “WARNING: Ref 'refs/heads/master' is unchanged”?

匿名 (未验证) 提交于 2019-12-03 01:49:02

问题:

I have been googling and reading various posts around the net and I've tried:

git filter-branch --index-filter "git rm -rf --cached --ignore-unmatch Launcher\lib" --prune-empty -- --all

and

git filter-branch --tree-filter "rm -rf Launcher\lib" --prune-empty -- --all

All resulting in a:

WARNING: Ref 'refs/heads/master' is unchanged

There are other clones of this repository and a central server also. I will push changes to the server, as I understand, others with clones just need to fetch and rebase (not merge)? Would it still work if they have made changes?

回答1:

Okay I solved the problem, it was the path that was wrong. I changed this:

Launcher\lib

to this:

Launcher/lib/

and now it works ;)



回答2:

I'm gonna put this here as a future reference since I had the same problem: If you use cmder (or other ConEmu flavors), use double quotes instead of single quotes.

Also wrap the path in quotes if you have some white space in your address:

git filter-branch --force --index-filter \ "git rm --cached --ignore-unmatch 'server/bin/some file.txt'" \ --prune-empty --tag-name-filter cat -- --all 

That was the problem when I got that error.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!