使用git skip-worktree来禁用文件更新,合并问题 [英] using git skip-worktree to disable file updates, issues with merge

查看:1006
本文介绍了使用git skip-worktree来禁用文件更新,合并问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们使用Git,IntelliJ和Maven。我们遇到了有关IntelliJ配置文件的一些问题。例如。 * .iml文件会根据项目是生成还是重新生成还是执行 mvn clean 而不断变化。我们知道IntelliJ中有一些错误会导致这些文件发生变化。

we use Git, IntelliJ and Maven. We encounter some issues with the configuration files for IntelliJ. E.g. the *.iml files constantly change depending on whether the project was build or re-build or a "mvn clean" was executed. We are aware there are some bugs in IntelliJ that causes these files to change.

计划使用 git update-index --skip -worktree 为所有* .iml文件(和其他一些文件)。这样,一个开发人员可以维护这些文件的适当状态,并且如果他们必须更改(新的依赖关系或模块)以重新启用跟踪,更改文件,然后切换回跳过的更改。所以其他开发者得到更新的文件,但他们的变化不会被推回到git仓库。

The plan was to use "git update-index --skip-worktree" for all *.iml files (and some others). This way one developer can maintain a proper state for these files and if they have to change (new dependencies or modules) to re-enable tracking, changing the files and then switch back to skipping changes. So other developers get the updated files but their changes are not pushed back into the git repository.

根据 http://fallengamer.livejournal.com/93321.html 这有一个工作机会。

According to http://fallengamer.livejournal.com/93321.html this has a chance of working.

这确实与本地测试存储库一起工作。但是一旦搬到遥控器,它开始表现出不同的表现。 git status 显示不需要做任何事情,但切换分支会产生一个消息,即本地更改将被覆盖(主要是被忽略的*,iml文件)尽管 git ls-files -v 显示了文件上的正确标志。
在IntelliJ中,有一个空的Window,它有相同的警告,所以这很麻烦。

This did work with a local test repository. But once moved to the remote it started to behave different. "git status" shows nothing has to be done but switching a branch brings up the message that local changes would be overwritten (mainly the *,iml files which are 'ignored') although "git ls-files -v" shows the right flag on the files. In IntelliJ there is an empty Window with the same warning, so that is rather confusing.

我在skip-worktree选项中出错了?它不应该在合并中生存吗?或者是它的行为意味着不同的目的?

What did I get wrong with the "skip-worktree" option? Is it not supposed to survive a merge? Or is its behaviour meant for a different purpose?

谢谢!

thanks!

推荐答案

<这个行为是打算的。
git update-index --skip-worktree (以及类似的选项 - assume-unchanged )旨在隐藏状态的一些修改。当你合并,并且合并即将改变这些文件时,我想说,Git警告你它并不是简单地覆盖你的修改。

This behavior is intended. git update-index --skip-worktree (as well as the similar option --assume-unchanged) is intended to hide some modifications from the status. When you merge, and the merge is about to change these files, I'd say, it is good that Git warns you about it instead of simply overwriting your changes.

以下是 man git-update-index 对此的解释:

Here is what man git-update-index says about that:


目录版本可能存在或不存在。如果存在,
的内容可能与索引版本匹配。写作不是
受此位影响,内容安全仍然是第一要务。注意Git可以更新工作目录文件
,即
skip-worktree,如果这样做是安全的话(即工作目录版本
与索引版本匹配)

The working directory version may be present or absent. If present, its content may match against the index version or not. Writing is not affected by this bit, content safety is still first priority. Note that Git can update working directory file, that is marked skip-worktree, if it is safe to do so (i.e. working directory version matches index version)






至于IntelliJ的行为,它也(以及 git status )不会检查某些文件是否标有此标志,因此当它试图显示您的差异时,它无法找到阻止合并的修改。您可以投票支持一对夫妇 有关 - 承担 - 不变的问题(它们大概与 - skip-worktree )。

这篇关于使用git skip-worktree来禁用文件更新,合并问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆