Can I get a list of files marked --assume-unchanged?

Git

Git Problem Overview


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.

Git Solutions


Solution 1 - Git

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

Solution 2 - Git

One Liner
git ls-files -v | grep "^[a-z]"
Use Aliases

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
About File Status

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 >

Solution 3 - Git

This command works more consistently for me. It will print only the files that are listed as 'assume-unchanged'.

git ls-files -v|grep "^h"

I've used this lots of times in different environments and it works perfectly.

Solution 4 - Git

PowerShell solution, using Select-String \ sls

git ls-files -v | sls -pattern ^h -casesensitive

Solution 5 - Git

Windows command line solution using findstr:

git ls-files -v | findstr /B h

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionRob WilkersonView Question on Stackoverflow
Solution 1 - GitAndrew AylettView Answer on Stackoverflow
Solution 2 - GitryenusView Answer on Stackoverflow
Solution 3 - Gitearl3sView Answer on Stackoverflow
Solution 4 - GitThowkView Answer on Stackoverflow
Solution 5 - GitVolodymyrView Answer on Stackoverflow