git - 如何在回购级别隐藏特定文件的更改 [英] git - how to hide changes for a particular file at a repo level
问题描述
我们在git中有一个文件,我们永远不想改变它。该文件具有产品附带的默认值。然而,当我们在本地运行一个构建过程时,这个文件会发生变化。
所以很自然这个文件会在人们忘记并提交时一直检查。
是的,我知道这是愚蠢的 - 但很难改变这种行为(不要问)....
有没有办法在repo级别标记这个文件,以便它永远不会在git状态中显示为已更改?如果回购中的版本被签出并且本地副本被覆盖,那就好了。
thoguhts?
谢谢
您可以尝试从 git update-index
:
git update-index --skip-worktree - path
- - [no-] skip-worktree
当指定其中一个标志时,路径中记录的对象名称不会更新。
相反,这些选项设置并取消路径的skip-worktree
位。
<可以在一个(长)句子中定义Skip-worktree 位:
当读入一个条目时,如果它被标记为skip-worktree
,那么Git假装它的工作目录版本是最新的,并且读取索引版本。
We have a file in git that we never want to change. This file has default values that the product ships with. However when we run a build process locally, this file gets changed.
So naturally this file gets checked in all the time as people forget and commit it.
And yes, I know this is dumb - but it's difficult to change this behavior (don't ask)....
Is there a way to mark this file at a repo level so that it never shows as changed in git status? It's fine if the version in the repo gets checked out and the local copy is overwritten.
thoguhts?
thanks
You can try, from the command git update-index
:
git update-index --skip-worktree -- path
--[no-]skip-worktree
When one of these flags is specified, the object name recorded for the paths are not updated.
Instead, these options set and unset the "skip-worktree
" bit for the paths.
Skip-worktree
bit can be defined in one (long) sentence:
When reading an entry, if it is marked asskip-worktree
, then Git pretends its working directory version is up to date and read the index version instead.
这篇关于git - 如何在回购级别隐藏特定文件的更改的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!