Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ignore .gitignore files in git status? [duplicate]

Tags:

git

gitignore

When I run git status, it lists a bunch of .gitignore files that I am not interested in seeing in the list (they got updated locally by Eclipse). I browsed numerous posts in regards to this seemingly common issue but none of the suggested solutions worked for me.

E.g. I went into ~/.gitconfig and found that

excludesfile = ~/.gitignore_global

Then I went into that file and added .gitignore at the tail but that did not change anything.

How do I effectively ignore .gitignore files in git status so they don't clutter the view?

like image 652
amphibient Avatar asked Sep 03 '13 22:09

amphibient


People also ask

How do I ignore a .gitignore file?

If you want to ignore a file that you've committed in the past, you'll need to delete the file from your repository and then add a .gitignore rule for it. Using the --cached option with git rm means that the file will be deleted from your repository, but will remain in your working directory as an ignored file.

Does Gitignore get cloned?

gitignore is created, the file will still be part of the repository and therefore cloned. Even that's an overstatement: an entry in a . gitignore file is only considered when some file is untracked. A committed file, as (because) it is being checked out, automatically becomes tracked.

How do I ignore a Git file without Gitignore?

Excluding local files without creating a .gitignore fileUse your favorite text editor to open the file called .git/info/exclude within the root of your Git repository. Any rule you add here will not be checked in, and will only ignore files for your local repository.

How do I ignore already added files in git?

Git can only ignore files that are untracked - files that haven't been committed to the repository, yet. That's why, when you create a new repository, you should also create a . gitignore file with all the file patterns you want to ignore.


2 Answers

It sounds like you might be misunderstanding what "ignore" means to Git. A file name mentioned in .gitignore means that if a file is untracked, then git status will not show that file as an untracked file.

Ignoring a file does not do anything when the file is tracked by Git, and has been modified. That is considered a change to your repository, which Git doesn't let you ignore. (After all, you have already told Git that file is important enough to store in your repository, so Git has an obligation to inform you about changes to that file.)

If your tools (Eclipse) is modifying your .gitignore files, I would suggest you instruct Eclipse to stop doing that.

like image 97
Greg Hewgill Avatar answered Oct 02 '22 03:10

Greg Hewgill


Try:

git status --ignored

From man git-status:

--ignored Show ignored files as well.

like image 23
user4552416 Avatar answered Oct 02 '22 02:10

user4552416