in Technology by
How to make Git “forget” about a file that was tracked but is now in .gitignore?

1 Answer

0 votes
by

.gitignore will prevent untracked files from being added (without an add -f) to the set of files tracked by git, however git will continue to track any files that are already being tracked.

To stop tracking a file you need to remove it from the index. This can be achieved with this command.

git rm --cached <file>

If you want to remove a whole folder, you need to remove all files in it recursively.

git rm -r --cached <folder>

The removal of the file from the head revision will happen on the next commit.

Related questions

0 votes
    How to make Git “forget” about a file that was tracked but is now in .gitignore?...
asked Jan 8, 2021 in Technology by JackTerrance
0 votes
    There is a file that was being tracked by git, but now the file is on the .gitignore list. However, ... completely forget about it? Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    Your online activity can still be tracked even if you use different Tor services, but not in much detail. 1) True 2) False...
asked Dec 30, 2020 in Technology by JackTerrance
0 votes
    My .gitignore file seems to be being ignored by Git - could the .gitignore file be corrupt? Which file format, ... looking to fix this? Select the correct answer from above options...
asked Feb 3, 2022 in Education by JackTerrance
0 votes
    Your friend has prepared a project report and now wants you to make use of a word feature so that one can see ... wants you to use. Select the correct answer from above options...
asked Dec 20, 2021 in Education by JackTerrance
0 votes
    What will be the output of following code? (2) Value= Simar Age=17 print(Value, , your are , 17, now but ) ... ,Age+1, next year ) Select the correct answer from above options...
asked Dec 13, 2021 in Education by JackTerrance
0 votes
    How can we make ignore file mode (chmod) changes in git?...
asked Jan 8, 2021 by JackTerrance
0 votes
    How to determine the URL that a local Git repository was originally cloned from?...
asked Jan 7, 2021 in Technology by JackTerrance
0 votes
    I pulled a project from GitHub a few days ago. I've since discovered that there are several forks on GitHub, ... those forks I pulled? Select the correct answer from above options...
asked Feb 2, 2022 in Education by JackTerrance
0 votes
    Could someone one clarify why my Eclipse (http://developer.android.com/sdk/index.html) from ADT won't ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jun 19, 2022 in Education by JackTerrance
0 votes
    Simran write a code print: (“hello friends”)but when she executed there comes an error what was the error and why did it occur Select the correct answer from above options...
asked Dec 23, 2021 in Education by JackTerrance
0 votes
    How code coverage is measured/tracked using Jenkins in a CI environment?...
asked Sep 14, 2021 in Technology by JackTerrance
0 votes
    How code coverage is measured/tracked using Jenkins in a CI environment?...
asked Jul 17, 2021 in Technology by JackTerrance
0 votes
    This is my code it's just starting the scan but it is not completing ,where is the error in it. ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 26, 2022 in Education by JackTerrance
...