Nic*_*eys 253
当然.
git update-index --assume-unchanged [<file> ...]
Run Code Online (Sandbox Code Playgroud)
要撤消并再次开始跟踪:
git update-index --no-assume-unchanged [<file> ...]
Run Code Online (Sandbox Code Playgroud)
Ger*_*ard 30
接受的答案不正确。--assume-unchanged只会导致 Git 跳过某些(有时是昂贵的)文件系统检查 - 它不能保证 Git 将文件显示为“未更改”。
然而,相同的命令但带有选项--skip-worktree确实有效。因此,为了防止已跟踪但已更改的文件在 Git 状态中显示为已更改,请使用
git update-index --skip-worktree [<file> ...]
Run Code Online (Sandbox Code Playgroud)
要撤消并开始再次将其显示为更改:
git update-index --no-skip-worktree [<file> ...]
Run Code Online (Sandbox Code Playgroud)
另请参阅本答案中引用的 Git 维护者的电子邮件、Git 文档git-update-index以及FallenGameR 的博客文章,了解两者如何对不同场景做出反应。
另一种方法(来自 Seth Robertson 现已删除的答案,但我发现它很有帮助,因此重新启动它)是维护一个“跟踪”模板文件,然后使用它的本地未跟踪版本,例如:“config.sample.ini”或“ config.ini.template"完整示例见https://gist.github.com/canton7/1423106。
然后,如果文件在 git 等中更改,则不会有任何问题,并且您可以在本地未跟踪的文件上使用 .gitignore(最终)。
在filter命令中使用git属性和%f的另一种解决方案:
git config filter.orig.clean "cat %f.orig"
cp filename filename.orig
echo "filename filter=orig" >> .git/info/attributes
echo "filename.orig" >> .git/info/exclude
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
45075 次 |
| 最近记录: |