How to add files from .gitnore folder back into project

118 Views Asked by At

I have several files that are hidden in Intellij 2017. It seems that the hidden files are in the .gitignore folder. I need those files. So I'm wanting to know how to add those files back into my project, and remove from .gitignore folder. The only search results I have seen is how to remove a file which will completely remove the files from my project.

2

There are 2 best solutions below

2
On BEST ANSWER

Here is the quote from git document:

An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. An optional prefix "!" which negates the pattern; any matching file excluded by a previous pattern will become included again. It is not possible to re-include a file if a parent directory of that file is excluded. Git doesn’t list excluded directories for performance reasons, so any patterns on contained files have no effect, no matter where they are defined. Put a backslash ("\") in front of the first "!" for patterns that begin with a literal "!", for example, "!important!.txt".

Example:

$ cat .gitignore
vmlinux*
$ ls arch/foo/kernel/vm*
arch/foo/kernel/vmlinux.lds.S
$ echo '!/vmlinux*' >arch/foo/kernel/.gitignore
0
On

A "clean explicit solution" I like to use is :

1st create a commit that removes (or comments out) the ignored paths from the .gitignore file.

2nd, create a commit to add all the files that are now not ignored in your working tree.

Of course this is to execute from a station that actually has the files you want to add into your git source control.