-2

Don't know why git status shows me all untracked files after "git status" as "tracked filed"

mkdir test
cd test 
git init
git remote add origin ORIGINURL
git fetch
git branch -b 'local_develop' origin/'develop'
ls -l 
/vendor/ 
.gitignore # .gitignore contains here /vendor/ 

composer install 
git status 

# I'm getting here list like:  
# deleted: vendor/file1.php
# deleted: vendor/file2.php 

Why is that? I do not want to see any information in my git status related to ignored files.

user88831
  • 177
  • 1
  • 1
  • 9
  • 2
    timsmelik is correct... but he doesn't tell you what to do about it. Very simply: `git rm -r --cached `. Look here for more details: https://stackoverflow.com/a/1274447/421195 – paulsm4 Dec 29 '20 at 20:30

1 Answers1

2

The listed files are probably already tracked.

Check the official .gitignore documentation:

A gitignore file specifies intentionally untracked files that Git should ignore. Files already tracked by Git are not affected; see the NOTES below for details.

From the same page:

To stop tracking a file that is currently tracked, use git rm --cached.

timsmelik
  • 732
  • 3
  • 11
  • I know that. That is why i provided full code example starts from"git init" how it's possible that git tracked files before "git init" i also tested before "composer install" i manually added file to vendor dir and after my manuall change i did not see any changes in "git status" – user88831 Dec 29 '20 at 20:31
  • 2
    @user88831 But you said `git fetch` and `git branch -b 'local_develop' origin/'develop'`. Those files were already in the remote repo, and now, presto, they are in _your_ repo and _your_ index. It doesn’t matter whether you ignore them now; it’s too late. They are present and tracked. You are punching yourself in the face and then complaining that someone is punching your face. :) – matt Dec 29 '20 at 20:38
  • "Those files were already in the remote repo, and now, presto, they are in your repo and your index. It doesn’t matter whether you ignore them now; it’s too late. " . So that would be correct way of init this repo? – user88831 Dec 30 '20 at 07:27
  • After "gir rm -r -cached vendor". I see those files as "green". I have to make commit now, i would prefer get them disappear from my index of them without any commit. – user88831 Dec 30 '20 at 07:42