Unused files still show in git status

I did not check some folders and files with .git / info / exclude:

doc *.txt doc/*.txt doc/somefile.txt 

But git status says it is still being tracked:

 $ git st # On branch dev # Changes not staged for commit: # (use "git add <file>..." to update what will be committed) # (use "git checkout -- <file>..." to discard changes in working directory) # # modified: doc/somefile.txt 

Another strange thing is that ls files show that it is not being tracked:

 $ git ls-files --ignored --exclude-from=.git/info/exclude doc/somefile.txt $ touch /tmp/xxx $ git ls-files --ignored --exclude-from=/tmp/xxx $ 

I am on git version 1.8.1.5

So, I came to the conclusion that I can misunderstand something or do something wrong. Any idea please?

+4
source share
3 answers

Since you are locally ignoring files in the repository, you need to tell git that you are ignoring them

 git update-index --assume-unchanged <files to forget> 
+6
source

You need git rm --cached <file> . This does not delete the file from your working directory, but it removes it from git cache , so now it will be included in. gitignore .

+3
source

Since the file is currently being monitored, you need to tell git to forget about them before ignoring them.

git rm --cached doc/somefile.txt

0
source

Source: https://habr.com/ru/post/1497410/


All Articles