Artem Kulakov
Artem Kulakov

Reputation: 29

The file is ignored by Git but it's not in .gitignore

I make changes in db/schema.rb, but Git doesn't see them while the file isn't included in .gitignore.

It's worth to mention that the editor (Sublime Text) doesn't grey out the file as it does for the files and folders listed in .gitignore.

I checked the following but none of them helped:

$ vi ~/.gitignore
$ git status -s --ignored
$ git check-ignore -v db/schema.rb

Upvotes: 0

Views: 90

Answers (1)

LeGEC
LeGEC

Reputation: 51860

From your comment :

The second command gives S db/schema.rb

The S indicates the skip-worktree flag, one of the not so visible flags that can be set through git update-index.

Run :

git update-index --no-skip-worktree db/schema.rb

to remove this flag.


references to the documentation :

The link with git ls-files to spot files having this flag is only mentioned in

  • this small sentence on git help update-index (last sentence in second paragraph in the "Using “Assume Unchanged” Bit", no direct mention from Skip-worktree paragraphs) :

To see which files have the "assume unchanged" bit set, use git ls-files -v (see git-ls-files[1]).

-t

[...] This option identifies the file status with the following tags (followed by a space) at the start of each line:

[...]

S
skip-worktree

-v

Similar to -t, but use lowercase letters for files that are marked as assume unchanged (see git-update-index[1]).

Upvotes: 1

Related Questions