Ignore deleted files in git?

霸气de小男生 提交于 2020-01-13 09:09:12

问题


Is it possible to ignore deleted files in git? git update-index --assume-unchanged allows me to ignore modifications, but it still tracks deletions.

(This is similar, but I couldn't find where "John Doe" restated his question: Ignore modified (but not committed) files in git?)


回答1:


Rather than trying to ignore the "delete" status, I would:

  • not remove the directory and those files in it
  • split the Git repo in two, effectively detaching the subdirectory to be removed into a separate Git repository.
  • go on with the main Git repo.

Note: that may not be compatible with a Git repo currently synchronized with a SVN one.




回答2:


The following stops will surely solve your problem:

  1. Ensure that all deleted files are not staged to commit. If they are staged, to unstage them you can simply do git reset

  2. After this step, run the following command

    git ls-files --deleted -z | git update-index --assume-unchanged -z --stdin

Note: The first command. git ls-files --deleted -z, lists all the deleted files as a string. Then it takes that as the input to the second command.



来源:https://stackoverflow.com/questions/2622926/ignore-deleted-files-in-git

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