Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Git ignore unignore not working?

Tags:

git

gitignore

I've looked at this answer: Unignore subdirectories of ignored directories in Git

And as far as I can tell I am doing the same thing, but git refuses to unignore my directories/files.

These are my rules. I'm trying to just get the listed directories/subdirectories, but the entire public directory is not showing up.

/public/bootstrap/*
!/public/bootstrap/bower_components/bootstrap/dist/*
!/public/bootstrap/bower_components/bootstrap/dist/**/*
!/public/bootstrap/bower_components/bootstrap/less/variables.less

Any ideas?

like image 841
Joren Avatar asked Oct 22 '14 19:10

Joren


People also ask

How do I unignore git?

under the git repository. You can use patterns with ! as the prefix to “unignore” files. From gitignore man page: An optional prefix “!” which negates the pattern; any matching file excluded by a previous pattern will become included again.

Is there a git ignore command?

There is no explicit git ignore command: instead the . gitignore file must be edited and committed by hand when you have new files that you wish to ignore. . gitignore files contain patterns that are matched against file names in your repository to determine whether or not they should be ignored.

How do I ignore a text file in Gitignore?

You have the option to use double Asterisk (**) to match any number of directories and files. For example, Test/**/*. txt will tell git to ignore only files ending with . txt in the test directory and its subdirectories.

Does git ignore any files by default?

git folder is ignored by default. All others are deamed potentially important for the source-base unless configured otherwise within the repository or at a global level.


1 Answers

A command line that helps testing if you got it right: https://git-scm.com/docs/git-check-ignore

The following CLI:

git check-ignore -v .idea/bbb.txt .idea/workspace.xml .idea/runConfigurations/Android_Debug___ReactNative.xml android/.idea/aaaa.txt android/.idea/runConfigurations/app.xml

Outputs the following:

.gitignore:33:**/.idea/**   .idea/bbb.txt
.gitignore:33:**/.idea/**   .idea/workspace.xml
.gitignore:35:!**/.idea/runConfigurations/* .idea/runConfigurations/Android_Debug___ReactNative.xml
.gitignore:33:**/.idea/**   android/.idea/aaaa.txt
.gitignore:35:!**/.idea/runConfigurations/* android/.idea/runConfigurations/app.xml

Pay attention that the 3rd and 5th lines are successfully un-ignored (watch for the "!" sign).

My .gitignore file:

**/.idea/**
!**/.idea/runConfigurations/
!**/.idea/runConfigurations/*
like image 132
A-S Avatar answered Sep 24 '22 19:09

A-S