389

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.

5 Answers 5

520

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
13
  • 47
    git ls-files -v | grep ^[a-z]
    – Matt R
    May 7, 2010 at 15:39
  • 18
    My OS apparently has a weird collation setup, so Matt's command didn't work for me. Here's what I added under the [alias] section of my .gitconfig: ignored = !git ls-files -v | grep "^[[:lower:]]" Sep 3, 2011 at 22:55
  • 15
    The reason [a-z] doesn't work is that the shell expands it as a wildcard; if the current directory contains a file that matches that pattern (ie a single lowercase letter), then the expansion of that is the name of the file. Try adding quotes, eg "[a-z]"
    – DomQ
    Mar 9, 2012 at 13:10
  • 8
    git ls-files -v | grep -e "^[a-z]" Apr 1, 2013 at 10:17
  • 15
    The suggested aliases work for finding unchanged files at the current directory and below. If you want a list of all "assume-unchanged" files in the repository, you'll need git ls-files -v `git rev-parse --show-toplevel` | grep "^[a-z]" May 15, 2013 at 15:43
92

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
3
  • 2
    Nice easy-to-remember aliases :) Thanks
    – Debajit
    Jun 29, 2016 at 20:56
  • 1
    Here are some more flexible variants: hidden = "!f() { git ls-files -v \"$@\" | grep \"^[a-z]\"; }; f" and ignored = "!f() { git status -s --ignored \"$@\" | grep \"^!!\"; }; f". This allows, for example, git ignored -- PATH1 PATH2 to only list ignored files in certain paths (useful when you have a lot of ignored files).
    – sls
    Jul 13, 2016 at 8:05
  • Thank you for alias
    – MOHRE
    May 17, 2017 at 6:11
30

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.

1
  • 5
    In the Windows prompt, use grep "^h" instead of single quotes Sep 29, 2015 at 12:00
11

Windows command line solution using findstr:

git ls-files -v | findstr /B h
9

PowerShell solution, using Select-String \ sls

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.