Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to tell git-status to ignore the effects of .gitignore files?

I have configured numerous .gitignore files to filter out many different unwanted files from a set of about 6,000 untracked files. I want to do git add . when I've got my filtered list looking the way I want it.

But, then I want to disable the .gitignore filters temporarily to see what got left behind, and make sure there was nothing important accidentally filtered.

I know that git-clean includes an option to ignore .gitignore files. Is there a similar option for git-status?

I could go through and delete all the .gitignore files, do the check, then restore them, but it seems there should be an easier way?

like image 891
davidA Avatar asked Jun 08 '10 03:06

davidA


People also ask

How do I force git to ignore a file?

Use Git update-index to ignore changes Or, you can temporarily stop tracking a file and have Git ignore changes to the file by using the git update-index command with the assume-unchanged flag.

How do I tell git to ignore a 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.

How do I ignore a .gitignore class file?

The easiest and most common way to ignore files is to use a gitignore file. Simply create a file named . gitignore in the repository's root directory. Then, add names and patterns for any files and directories that should not be added to the repository.

Does git add ignore Gitignore?

The . gitignore file tells Git which files to ignore when committing your project to the GitHub repository. gitignore is located in the root directory of your repo. / will ignore directories with the name.


2 Answers

This option --ignored does the trick:

git status --ignored 



(Update 1) I found the --ignored option alone doesn't work in certain git installations, perhaps it's a git bug. In those cases, an additional -s works for me:

git status -s --ignored 

(Update 2) One user reported --ignored option is not supported in git version 1.7.0.4. My git version is 1.7.6. Another version 1.7.5.1 is the one that requires -s. You may try

git status -h 

to see if --ignored is supported.

like image 117
5 revs Avatar answered Sep 19 '22 18:09

5 revs


Try using git ls-files --other - it should list all files that git doesn't know about; i.e. those files that aren't in the repository and aren't ignored by .gitignore.

You can also use git ls-files --ignored --exclude-standard to see what files git is explicitly ignoring.

like image 36
Blair Holloway Avatar answered Sep 23 '22 18:09

Blair Holloway