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, 2021 in Git & GitHub by akhtar
• 38,230 points
445 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, 2021 by MD
• 95,440 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,440 points
15,247 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,440 points
753 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
2,218 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,610 points
20,442 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
3,504 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,440 points
14,328 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,440 points
678 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