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,170 points
68 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,160 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,550 points
1,956 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 6, 2018 in Git & GitHub by Sophie may
• 10,550 points
8,081 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 27, 2020 in Git & GitHub by Mudit
94 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,170 points
115 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 26, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
1,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,160 points
2,553 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,160 points
255 views