开发者

Who touched my git assume-unchanged bit?

I have a certain file in my repo that I have set the assume unchanged bit on:

git update-index --assume-unchanged someFile.txt

Once in a while, after some work on the repo, that bit is unset and the file is automagically not assume-unchanged anymore.

Who's touching it? How can I make this permanent until I explicitly tell git to:

git update-index --no-assume-unchanged someFile.txt

What's going on here?


Edit: I'm using the assume-unchanged bit on configuration files that change locally, and should never ever be committed, not to mention pushed upstream. I don't 开发者_开发知识库want to see them in git status, nor anywhere else, unless I explicitly tell git I want to edit and commit one of them.


Edit: OK, I think I managed to reproduce the issue.

I committed the file from a different repo (which didn't have it as --assume-unchanged), pulled on my repo, and sure enough, the bit was reset.

So two questions arise:

  1. Is it possible to set this bit on the central authoritative repo so that it propagates to all repos?
  2. Is it possible to make this bit sticky, even after remote changes to it?


IIRC if you ignore a versioned file, it will behave like that. You can ignore across all work trees from .gitignore or in particular work tree from .git/info/exclude (yes, it works, but is not intended way of doing things).


It seems that --skip-worktree + sparse checkout could allow this sort of behavior.

From git assume unchanged vs skip worktree - ignoring a symbolic link (with some contextual modifications):

  • Set core.sparseCheckout to true for the repository.
  • Create a file .git/info/sparse-checkout containing two patterns: * to include everything and !/path/to/someFile.txt to exclude local file 'someFile.txt'.
  • Now, manually set the skip-worktree bit to someFile.txt.

Now you can go on without having to fear that git will automatically commit the directory, but note that you will still run into problems if someone explicitly runs git add on the directory or any file in it.

Further research in the man page seems to indicate that --skip-worktree is more appropriate for the use case being asked about.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜