Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

untracked files still appear in git status

Tags:

git

I have untracked some folders and files by using .git/info/exclude :

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

But git status says it is still 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

Other weird thing is that ls-files shows it is untracked :

$ 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 conclude I may misunderstand something or do something wrong. Any idea please ?

like image 921
lalebarde Avatar asked Aug 16 '13 10:08

lalebarde


People also ask

Does git status show untracked files?

If git status mentions "Untracked files:", you may need to add one or more untracked files. This status message is OK. We are up-to-date, there is nothing to commit, but there is still an untracked file.

Why do I have untracked files in git?

Untracked files are those that are in the repo's directory but have not yet been added to the repo's index with git add .

What happens to untracked files in git?

Untracked basically means that Git sees a file you didn't have in the previous snapshot (commit), and which hasn't yet been staged; Git won't start including it in your commit snapshots until you explicitly tell it to do so.


2 Answers

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

git update-index --assume-unchanged <files to forget>
like image 112
Abizern Avatar answered Oct 04 '22 20:10

Abizern


You need to git rm --cached <file>. This doesn't remove the file from your working directory, but it removes it from the git cache so it'll now be included by the .gitignore.

like image 45
Nicholas Smith Avatar answered Oct 04 '22 21:10

Nicholas Smith