What have I marked as --assume-unchanged
? Is there any way to find out what I've tucked away using that option?
I've dug through the .git/
directory and don't see anything that looks like what I'd expect, but it must be somewhere. I've forgotten what I marked this way a few weeks ago and now I need to document those details for future developers.
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]).
You can type git update-index --assume-unchanged <file> to temporarily exclude the file from any tracking, pretending it never changed. And when you actually need to commit some actual change to the file you can use the opposite command git update-index --no-assume-unchanged <file> .
You can use git ls-files -v
. If the character printed is lower-case, the file is marked assume-unchanged.
To print just the files that are unchanged use:
git ls-files -v | grep '^[[:lower:]]'
To embrace your lazy programmer, turn this into a git alias. Edit your .gitconfig
file to add this snippet:
[alias] ignored = !git ls-files -v | grep "^[[:lower:]]"
Now typing git ignored
will give you output like this:
h path/to/ignored.file h another/ignored.file
git ls-files -v | grep "^[a-z]"
IMHO, git hidden
is better for files marked as --assume-unchanged
:
git config --global alias.hidden '!git ls-files -v | grep "^[a-z]"'
Here's a list of related aliases I have in ~/.gitconfig
:
[alias] hide = update-index --assume-unchanged unhide = update-index --no-assume-unchanged unhide-all = update-index --really-refresh hidden = !git ls-files -v | grep \"^[a-z]\" ignored = !git status -s --ignored | grep \"^!!\"
To make it work in subdirectories and support arguments:
hidden = "!f(){ git -C \"$GIT_PREFIX\" ls-files -v \"$@\" | grep \"^[a-z]\";}; f" ignored = "!f(){ git -C \"$GIT_PREFIX\" status -s --ignored \"$@\" | grep \"^!!\";}; f"
For example:
# cd target # git ignored classes
For me most hidden files are marked with flag h
, though there're actually several other flags according to the manual of git-ls-files
-v
:
-v Similar to -t, but use lowercase letters for files that are marked as assume unchanged (see git-update-index(1)).
About git ls-files
-t
:
This option (-t) identifies the file status with the following tags (followed by a space) at the start of each line: H cached S skip-worktree M unmerged R removed/deleted C modified/changed K to be killed ? other
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