78

I have used git update-index --skip-worktree <file> as suggested here to make git ignore local changes to a tracked file. But now I have forgotten which files I have applied it to. How can I list all files that have skip-worktree flag applied to them?

Community
  • 1
  • 1
1615903
  • 32,635
  • 12
  • 70
  • 99

2 Answers2

116

Use the following command if on *nix (Linux, Mac):

git ls-files -v . | grep ^S

or, if on Windows, you can use:

git ls-files -v . | findstr "^S"

Explanation: git ls-files . lists all files in the repo (assuming you are in the root folder). -v makes the output verbose, meaning that it will abbreviate the file status with a letter in front of the filename. The options are:

H cached

S skip-worktree

M unmerged

R removed/deleted

C modified/changed

K to be killed

? other

Documentation

So, to only list files with skip-worktree flag, the output is piped to grep with ^S as argument, meaning that only lines beginning with S are listed.

sazzad
  • 5,740
  • 6
  • 25
  • 42
1615903
  • 32,635
  • 12
  • 70
  • 99
  • 3
    When using fish shell, you'll have to enclose the argument for grep in quotes (`git ls-files -v | grep '^S'`) because in fish shell the caret has special meaning (redirect `stderr`). – anothernode Sep 05 '17 at 10:37
  • For me on Git bash capital S is showing no result but small s works. – Priyank Dec 12 '17 at 01:53
  • 4
    Along the same idea, but for Windows, using powershell, use this: `git ls-files -v . | select-string -pattern ^S` – Jean Libera Mar 27 '18 at 13:48
  • 4
    Using Cmder or Git Bash for Windows: `git ls-files -v | grep "^S"` – brt Aug 22 '18 at 16:58
  • 5
    For windows plain command line: `git ls-files -v . | findstr "^S"` – Adrián E Jan 30 '19 at 13:38
  • 1
    Excellent answer, but the manual strangely marks `-t/-v/-f` as semi-deprecated options. Yet, this answer provides the only way I can find to list skipped files. Is there a more canonical answer to this question, or is the semi-deprecated note in the manual for other functionalities than this? – joanis Feb 02 '22 at 15:02
8

For those using Tortoise Git, right click on the folder and choose TortoiseGit > Check for modifications, then only check Show ignore local changes flagged files.

If you want to stop ignoring a file, right click on it and choose Unflag as skip-worktree and assume-unchanged.

user276648
  • 6,018
  • 6
  • 60
  • 86