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:
In order to set "assume unchanged" bit, use --assume-unchanged option. To unset, use --no-assume-unchanged . To see which files have the "assume unchanged" bit set, use git ls-files -v (see git-ls-files[1]).
--skip-worktree explained: This allows you to make changes to a file that you don't want to be pushed to upstream. Use this option as already shown above.
The DROP INDEX command is used to delete an index in a table.
The Git index is a critical data structure in Git. It serves as the “staging area” between the files you have on your filesystem and your commit history. When you run git add , the files from your working directory are hashed and stored as objects in the index, leading them to be “staged changes”.
IIRC if you ignore a versioned file, it will behave like that. You can ignore across all work trees from (yes, it works, but is not intended way of doing things)..gitignore
or in particular work tree from .git/info/exclude
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With