【问题标题】:How to `--assume-unchanged` file in project?如何在项目中`--assume-unchanged` 文件?
【发布时间】:2018-06-01 08:42:48
【问题描述】:

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

【问题讨论】:

  • 您不应该在问题中使用gc,因为它是您的本地别名,无法普遍理解。请edit问题并用git checkout替换它。
  • @phd:完成........

标签: git git-assume-unchanged


【解决方案1】:

不要使用--assume-unchanged,它应该用于解决大文件不更改的性能问题,并且在执行git status 时散列成本很高。

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

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

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

【讨论】:

    【解决方案2】:

    删除假设不变的位:

    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
    

    【讨论】:

    • 而这一切我都想逃避。也许有像rebase.autostash true这样的选项?
    • @EugenKonkov 也许制作一个 bash 函数,它以分支名称和隐藏的文件路径作为参数。
    猜你喜欢
    • 2013-06-16
    • 2012-08-30
    • 2013-12-26
    • 2018-03-03
    • 2013-04-27
    • 1970-01-01
    • 2011-08-31
    • 1970-01-01
    相关资源
    最近更新 更多