I may be looking at the wrong tool for this, but I have a system that has configured like this: $HOME/module/submodule/{bin,config,log,tmp}, on multiple servers. I would like to add source control to all of the config directories, and none of the others (especially log!). I'm guessing that I could point git at $HOME and use .gitignore to exclude everything I'm not interested in, but new modules can get added from time to time, meaning a lot of stuff I'd want to immediately exclude. Any ideas? Am I missing something obvious? BTW, I'm not married to git, I'd accept any system that meets my needs. A central change repository would be nice but isn't a requirement; I just want a way to roll-back mistakes, and also add some change tracking.
-
Git isn't working out and Hg isn't looking very likely (but haven't actually tested it yet). I may need to just bite the bullet and add a .git/ and .gitignore to all of the submodule directories. Not as pretty as I'd like... – samwyse Oct 20 '15 at 23:17
2 Answers
.gitignore is a quite powerful way to do that.
If you want to exclude everything also in the future and have no dirs or files automatically added, but a few directories already present, you can use the *
pattern and !
prefix.
It follows an example of a .gitignore
to put in your root directory:
# exclude files in the root dir
/*
# exclude dirs in the root for
/**/
# include back the dirs below mentioned
!/bin/
!/config/
!/tmp/
Note. Sorry, but I'm not at my laptop and I cannot try it, so I'm writing the example out of my head. Look at the documentation for any detail.

- 49,335
- 19
- 95
- 187
-
Unfortunately, "It is not possible to re-include a file if a parent directory of that file is excluded." So the /**/ excludes the config, and subsequent lines won't get it back. Nor, apparently, will any variations of hard-coding the entire path, like !/module1/subdir1/config/* that I've tried. – samwyse Oct 20 '15 at 23:12
-
sorry if I'm late, I've just tried the solution proposed in the answer and it works perfectly. did you try it? could it be that you are doing something wrong with your *.gitignore* file? the fact is that the parent directory of the files you want to include are not excluded, for you re-include them by means of the lines starting with `!`, so your comment does not make much sense. – skypjack Oct 22 '15 at 15:29
Dumb and obvious way
Create repository with %REPO-ROOT
at $HOME
(as you think), ignore all files (syntax is VCS-dependent) before adding anything in repo, add by hand only needed files into repo
Slightly different version: ignore all except PATH/TO/config
dirs (it's theoretically possible with Negative Lookahead in Mercurial, the same technique under the different name exist in Git also, AFAICR), on debug stage hg-isignored extension (source on BitBucket) will be extremely useful - for Mercurial's regexp
More nice'n'easy way
Create repository with %REPO-ROOT
at each $HOME/module/submodule/config
and ignore nothing (?). Link all small repos in super-repo with Git's submodules|subtrees, Mercurial's subrepos or just use multiple remotes and branches in local repo (aggregation of LIVE-repositories)
Final note
Forget about RCS (also CVS, Monotone, Bazaar, ClearCase, Rational Team Concert), don't buy headache

- 1
- 1

- 94,711
- 9
- 78
- 110