Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Git clean -x option

In git-clean documentation, it says:

-x

Don’t use the standard ignore rules (see gitignore[5]), but still use the ignore rules given with -e options from the command line. This allows removing all untracked files, including build products. This can be used (possibly in conjunction with git restore or git reset) to create a pristine working directory to test a clean build.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

While the output of git clean -h says:

...
-x                    remove ignored files, too
...

Aren’t they contradictory? In my understanding, the standard ignore rules is rules from file .gitignre and .git/info/exclude, etc. According to the documentation, ignored files defined in file .gitignore shouldn’t be cleaned by git clean -fdx, but in fact they are.

>Solution :

No, they’re not. When it says, "don’t use the standard ignore rules", it means, "don’t ignore (i.e., don’t prevent the removal of) files that match the standard ignore rules; treat them as any other untracked files."

Normally files that are ignored are preserved with git clean -df, but with -x, these files are not ignored because the standard ignore patterns are not considered, so the files are considered untracked and hence removed.

You are correct about what the standard ignore rules comprise.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading