Git ignore locally deleted folder

2020-05-11 10:44发布

I have a Ruby on Rails application which crashes when vendor/rails is present but works fine if it is not. I need to keep this folder deleted in my local copy so that I can work, but I don't want this deletion to ever be committed. Someone put it there for a reason.

So how do I delete this folder without it coming up in git status as a thousand deleted files? Obviously .gitignore won't work since you can't ignore files which are already tracked. Neither do any of the solutions listed here (git update-index --assume-unchanged) work.

标签: git ignore
1条回答
一纸荒年 Trace。
2楼-- · 2020-05-11 11:22
 git ls-files --deleted -z | git update-index --assume-unchanged -z --stdin

Note that because this is an index-based operation, you cannot set directories to be ignored – only individual files. If upstream ever adds a file inside those directories, you will have to repeat the fix-up.

查看更多
登录 后发表回答