2

I have a folder public/lib which was ignored by GIT as i added following to .gitignore file :

public/lib

I made initial committ & pushed changes into remote repository. Later realized i need to commit one folder in public/lib called templates. Then found this approach for Make .gitignore ignore everything except a few files

Changed my .gitignore file to :

public/lib
!public/lib/template/**/*

This is not helping me. I dont see template folder considered by GIT on next git status.

I am new to Git.

Community
  • 1
  • 1
BeingSuman
  • 3,015
  • 7
  • 30
  • 48

1 Answers1

1

Your whitelist for the subdirectory looks a bit off to me. Try this:

public/lib              # blacklist public/lib folder
!public/lib/template    # but exclude the template subfolder
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360
  • After adding `!public/lib/template` in `.gitignore`, i expect `git status` to show `template` folder as untracked folder so that i can commit it next. Thats not happening @Tim. This is driving me nuts !!!! – BeingSuman Sep 18 '16 at 11:25
  • You can't add empty folders in Git. Please add a file to `public/lib/template` and then try `git status` again. – Tim Biegeleisen Sep 18 '16 at 11:27
  • `template` folder already has `css` & `js` folder, which in turn have files inside them !! When i try `git status --ignore` its showing `public/lib` folder under `Ignore Files` section. – BeingSuman Sep 18 '16 at 11:36
  • Yes. `git status` doesn't show `public/lib` but `git status --ignore` does in `Ignored Files` section. – BeingSuman Sep 18 '16 at 16:02
  • But are the files under `public/lib/template` visible? This was the whole point of your question. – Tim Biegeleisen Sep 18 '16 at 22:41
  • no they are not visible even after following the pattern given by you in `.gitignore` file. I had to force add & then commit the `public/lib/template` folder. – BeingSuman Sep 19 '16 at 04:56