How to force git to completely forget about a file that is present in gitignore folder

0 votes

Hi Team,

I have one file in 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?

Dec 22, 2020 in Git & GitHub by akhtar
• 38,260 points
3,663 views

1 answer to this question.

0 votes

Hi@akhtar,

gitignore file is a text file that tells Git which files or folders to ignore in a project. A local . gitignore file is usually placed in the root directory of a project. You can also create a global . gitignore file and any entries in that file will be ignored in all of your Git repositories.

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>
answered Dec 22, 2020 by MD
• 95,460 points

Related Questions In Git & GitHub

0 votes
1 answer

How to forcefully commit a file to Git even if the file is ruled as unchanged?

This is simple, just follow the below ...READ MORE

answered Jul 11, 2018 in Git & GitHub by Sophie may
• 10,620 points
14,216 views
0 votes
1 answer

How to give a file execute mode permissions in Git?

You can easily do this in one ...READ MORE

answered Aug 7, 2018 in Git & GitHub by Sophie may
• 10,620 points
21,110 views
0 votes
1 answer

I want to create a repository on folder level in Git. Is this possible?

That is possible but ideally, you should ...READ MORE

answered Sep 28, 2020 in Git & GitHub by Mudit
717 views
0 votes
0 answers

How to find and restore a deleted file in a Git repository?

Hi Team, I have one Git repository. I ...READ MORE

Dec 22, 2020 in Git & GitHub by akhtar
• 38,260 points
857 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,064 views
+2 votes
1 answer
0 votes
1 answer

How to untrack a file in Git?

Hi@akhtar, You can untrack your file from git ...READ MORE

answered May 4, 2020 in Git & GitHub by MD
• 95,460 points
13,510 views
0 votes
1 answer

How to unstage a file in Git?

Hi@akhtar, Sometimes we accidentally add files in the ...READ MORE

answered Nov 19, 2020 in Git & GitHub by MD
• 95,460 points
845 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP