Ignore (no commit) locally deleted files tracked by Git

情到浓时终转凉″ 提交于 2019-12-10 09:40:27

问题


I need delete file from file system which is tracked by Git repository and I want leave that file in Git repository unchanged (no commit to repo). It's easy for locally modified file where I'm using assume-unchanged option of update index and it works just fine. I need same behavior for deleted files.

I've tried this with no success:

  1. git update-index --assume-unchanged <file>
  2. Add file to .git/info/exclude

回答1:


If you run git update-index --assume-unchanged <file> before you delete the file then this will work. e.g.

$ git update-index --assume-unchanged <file>
$ rm <file>
$ git status
# On branch master
nothing to commit, working directory clean


来源:https://stackoverflow.com/questions/21902160/ignore-no-commit-locally-deleted-files-tracked-by-git

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