1

I have the following in my .gitignore:

*.log
/bower_components/*
/node_modules
!/bower_components/v-accordion
!/node_modules/todomvc-app-css/*

I added the last two lines after I installed those components, so that may be the issue, but I cannot tell.

Either way, I would like to track changes to those directories as I am actively customizing them and pushing to production.

However, I cannot seem to get Git to track them.
What am I doing wrong and how can I resolve this?

Edit:

Newer version of .gitignore:

*.log

/bower_components/**
!/bower_components/v-accordion/
!/bower_components/v-accordion/**

/bower_components/angular-bootstrap-calendar/
!/bower_components/angular-bootstrap-calendar/
!/bower_components/angular-bootstrap-calendar/**

/node_modules/
/node_modules/**
!/node_modules/todomvc-app-css/
!/node_modules/todomvc-app-css/**
MadPhysicist
  • 5,401
  • 11
  • 42
  • 107

1 Answers1

3

However, I cannot seem to get Git to track them

Simply check with:

git check-ignore -v -- node_modules/todomvc-app-css/afile

That will confirm the rule in a .gitignore which prevents you to track that file.

The rule is simple:

It is not possible to re-include a file if a parent directory of that file is excluded.

You need to exclude folders first before excluding content:

*.log

/bower_components/**
!/bower_components/v-accordion/**/
!/bower_components/v-accordion/**

/node_modules/**
/node_modules/todomvc-app-css/**/
!/node_modules/todomvc-app-css/**
Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • I first edited the .gitignore file, then ran the command you suggested. However, when I make changes to the file, and run `git status` it still does not register any changes. Any idea what is happening? – MadPhysicist Aug 01 '16 at 00:46
  • @MadPhysicist What `git check-ignore -v -- node_modules/todomvc-app-css/afile` (replace '`afile`' appropriately) returns? – VonC Aug 01 '16 at 06:30
  • This: `.gitignore:9:!/bower_components/angular-bootstrap-calendar/** bower_components/angular-bootstrap-calendar/dist/css/angular-bootstrap-calendar.css` Note, I am using a different file from that of the original question. I edited .gitingore as shown in my edit to the question. – MadPhysicist Aug 01 '16 at 17:53
  • @MadPhysicist OK, I have edited my answer: you actually want to exclude *all* the subfolders, as in `!/bower_components/v-accordion/**/` (not the final `/**/` at the end). Then you can exclude files. – VonC Aug 01 '16 at 17:56
  • What is the difference between `/**` and `/**/` – MadPhysicist Aug 01 '16 at 19:59
  • @MadPhysicist `/**` is for all files and folders recursively., `/**/` is for folders only (still recursively).As I said, you need to exclude folders first, then files. Try it out. It will work. – VonC Aug 01 '16 at 20:09