忽略(无提交)Git跟踪的本地删除文件 [英] Ignore (no commit) locally deleted files tracked by Git

查看:112
本文介绍了忽略(无提交)Git跟踪的本地删除文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从Git存储库跟踪的文件系统中删除文件,并且我希望将该文件保留在Git存储库中(不提交回购)。对于本地修改的文件,使用更新索引的假设不变选项很容易,并且效果很好。对于删除的文件,我需要具有相同的行为。

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.

我尝试失败了:


  1. git update-index-假定未更改的< file>

  2. 将文件添加到 .git / info / exclude

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


推荐答案

如果您运行 git update-index-假定未更改< file> 之前,然后删除文件即可。例如,

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

这篇关于忽略(无提交)Git跟踪的本地删除文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆