Reputation: 8160
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.
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.
According to http://fallengamer.livejournal.com/93321.html this has a chance of working.
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.
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!
Upvotes: 1
Views: 1865
Reputation: 3855
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.
Here is what man git-update-index
says about that:
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)
As about behavior of IntelliJ, it also (as well as git status
) doesn't check if some files are marked with this flag, so when it tries to show you differences, it can't find modifications which prevent the merge. You may vote for a couple of issues related to --assume-unchanged
(they are probably totally the same for --skip-worktree
as well).
Upvotes: 2