Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

git

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.

like image 665
Rob Wilkerson Avatar asked Mar 02 '10 13:03

Rob Wilkerson


People also ask

How to see assume unchanged Git?

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]).

What is assume unchanged in Git?

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> .


2 Answers

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 
like image 186
Andrew Aylett Avatar answered Sep 30 '22 00:09

Andrew Aylett


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 
like image 45
ryenus Avatar answered Sep 30 '22 01:09

ryenus