How to ignore certain files in Git

0 votes

Hi Team,

I have a repository with a Java file. When I compile it, an additional class file is generated. I created an entry for the class file in a .gitignore file. However, the file still appears to be tracked. How can I make Git ignore the class file?

Jan 4 in Git & GitHub by akhtar
• 38,180 points
71 views

1 answer to this question.

0 votes

Hi@akhtar,

The problem is that .gitignore ignores just files that weren't tracked before (by git add). Run git reset name_of_file to unstage the file and keep it. In case you want to also remove the given file from the repository (after pushing), use git rm --cached name_of_file.

answered Jan 4 by MD
• 95,220 points

Related Questions In Git & GitHub

0 votes
1 answer

How to stash untracked files of the current working directory in Git?

Hi@akhtar, In order to stash untracked files, add ...READ MORE

answered Nov 20, 2020 in Git & GitHub by MD
• 95,220 points
441 views
0 votes
1 answer

How to list all the files in a commit in Git?

Hi@akhtar, Using git diff-tree is considered as a preferred way ...READ MORE

answered Dec 22, 2020 in Git & GitHub by MD
• 95,220 points
108 views
0 votes
1 answer

How to do a re-merge into another branch in git

Seems like you want to rebase your ...READ MORE

answered May 7, 2018 in Git & GitHub by DareDev
• 6,890 points
950 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,969 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,138 views
+2 votes
1 answer
0 votes
1 answer

How to find the hidden files in the Git repository?

Hi@akhtar, To find the hidden files in the ...READ MORE

answered Nov 19, 2020 in Git & GitHub by MD
• 95,220 points
969 views
0 votes
1 answer

How to save files in Git Stash?

Hi@akhtar, Git Stash temporarily save changes you've made to ...READ MORE

answered Nov 20, 2020 in Git & GitHub by MD
• 95,220 points
187 views