+5 votes
1 view
in Devops and Agile by (29k points)
edited by

There is a file that was being tracked by git, but now the file is on the .gitignore list.

However, that file keeps showing up in git status after it's edited. How do you force git to completely forget about it?

1 Answer

+5 votes
by (49.5k points)
edited by

To stop tracking a file you need to remove the file from index.

For removing a file from the index:

git rm --cached<file>

Note: This command will not delete a physical file in local it will delete the file from other developers from the next $git pull command.

Also, you can go with the following commands

git rm -r -- cached.

git add .

Then commit the file with -am then the file gets updated and then the file cannot be tracked.

.gitignore will prevent untracked files from being added so instead of .gitignore you can remove the file from the index so that the file cannot be tracked.

For better understanding about these commands go through the following crash course on git that will help you to understand git well

Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...