如何在项目中`--assume-unchanged`文件?

How to `--assume-unchanged` file in project?

我有配置文件:conf/local.conf我运行下一个命令:

git update-index --assume-unchanged local.conf

在我切换到另一个分支或拉动之前都可以。

如何在分支之间保留 --assume-unchanged 标志?

UPD
即将发生的事情的一些例子:

$ git checkout 296-ToS-component 
error: Your local changes to the following files would be overwritten by checkout:
    conf/local.conf
Please commit your changes or stash them before you switch branches.
Aborting
$ git checkout -f 296-ToS-component 
error: Entry 'conf/local.conf' not uptodate. Cannot merge.

我希望它像下一个一样工作:

  1. conf/local.conf 保存
  2. 分支已切换
  3. conf/local.conf 被保存的版本替换

删除假设不变的位:

git update-index --no-assume-unchanged local.conf

保存:

git stash

切换分支:

git checkout 296-ToS-component

检索保存的版本:

git show stash@{0}:local.conf > local.conf

或将保存的版本与当前版本合并:

git stash apply

并且可能存在冲突,可以手动解决。

设置假定不变位:

git update-index --assume-unchanged local.conf

不要使用 --assume-unchanged,它应该用于大文件不更改的性能问题,并且在执行 git status.

时散列的成本很高

您想要的是 --skip-worktree 做几乎相同的事情,但要处理您更改但不想提交的文件。

它可能(不确定,但是嘿!这是你必须做的...)解决你的问题...