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?
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.
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.
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.
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.
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.
Try:
git status --ignored
From man git-status
:
--ignored Show ignored files as well.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With