S
S
sinevik2018-05-10 13:34:51
git
sinevik, 2018-05-10 13:34:51

Why do I add files to .gitignore, but they are still being tracked?

Why do I add files to git ignore, but it still tracks them?
Can't switch to another branch because of this
5af420b45323e493133787.png5af4203426872345410141.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
J
JimmDiGreez, 2018-05-10
@sinevik

Because they were already in the index.
https://git-scm.com/docs/git-rm#git-rm---cached
allows you to remove files from the index, respectively, gitignor will affect them.
git rm -rf --cached ios/buildFor example.
Let me explain.
-r - recursively go through the given directory.
-f - so as not to swear at anything.
The -rf entry is allowed by convention.
--cached - remove only from the index (not the files themselves).
ios/build - let to the folder in which to carry out this execution. (you can also write down the full path)
leave the package-lock.json by the way.

I
Igor Sivitsky, 2019-01-11
@fenek644

$ echo debug.log >> .gitignore
$ git rm --cached debug.log
(This removes (rm) 'debug.log')
$ git commit -m "Start ignoring debug.log"
The last command is important, I don't have it didn't work.. From here https://www.atlassian.com/git/tutorials/saving-cha... ignoring-a-previously-committed file

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question