Shan C
Shan C

Reputation: 107

Git --skip-worktree not working as intended

I know we have lot of discussions on this out here but those aren't solving my issue. So placing my question here.

I want to untrack some files from being shown as modified while doing git status, and I tried different options as explained here

ex. I want to untrack test.txt file and I tried like these:

git update-index --skip-worktree test.txt

Immediately, when I do git status, still it is showing as modified. Is there something wrong here? Also, I tried adding this to .git/info/exclude file but no luck. Can anyone please throw some ideas here?

Upvotes: 2

Views: 3020

Answers (2)

Satish Kumar
Satish Kumar

Reputation: 213

The files must have already been in the staging area before you flagged them. You must first remove them from the staging area to exclude them.

First, run 'git reset' to remove the files from staging.

Then, run the 'git update-index' command to flag the files as Skip-Worktree/Assume-Unchanged.

Upvotes: 2

VonC
VonC

Reputation: 1324515

Simply remove it from git status would be:

git reset -- afileBeginModified

But untracking completely would be a combination of:

git rm --cached -- afile_I_Dont_want_to_see_ever
echo afile_I_Dont_want_to_see_ever > .gitignore

Upvotes: 0

Related Questions