1

我有配置文件: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 被保存的版本替换
4

2 回答 2

4

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

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

https://stackoverflow.com/a/13631525/717372

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

于 2018-06-01T14:24:54.900 回答
0

删除假设不变的位:

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
于 2018-06-01T13:51:54.890 回答