Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
950 views
Welcome To Ask or Share your Answers For Others

1 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...