0

I work on a project in a team and I need to checkout branches of others from time to time. Here is the thing.

All CSS and JS files are compiled from SASS/Coffeescript and it's all stored in /Static directory. Obviously the compiled files are not included in remote repository. So I clone repository and compile them so I can run it on my local machine. I put the /Static directory into .gitignore.

Now let's say I run a checkout to a different branch. Everytime I do that, it aborts because there are uncommited files (those compiled ones). If I run git checkout <branch> --force they obviously dissapear, so I have to compile them everytime I run a checkout.

So, how can I make git completely ignore /Static directory (or any other I'd possibly want to) when commiting, checkout or any other operation? In other words: How can I make directories inside repository completely inactive in terms of git operations? Thanx

Michal Artazov
  • 4,368
  • 8
  • 25
  • 38

2 Answers2

1

You should add /Static to .git/info/exclude in your repository. It acts as a repository-wide mechanism for ignoring files.

John Szakmeister
  • 44,691
  • 9
  • 89
  • 79
1

I think you're not really ignoring /Static. If /Static was really ignored, you could be able to do what you want without problems.

What I think is that you have added /Static to .gitignore, but /Static was previously being control-versioned, so the inclusion in .gitignore has no effect.

I mean, if the initial clone contained /Static, that means /Static was being control-versioned. To start ignoring something that was previously versioned, you have first to stop control-versioning it:

git rm --cached <your-directory>

and then to start ignoring it

<add your directory to .gitignore>
git commit -m "Removed <directory> from control version."
elmart
  • 2,324
  • 15
  • 17