Is there an (open source) VCS that can work with a whitelist instead of a blacklist?

70 views Asked by At

I'm looking for an open source version control system that can be configured to track only a small number of individual files spread around the filesystem. Something like the opposite of .gitignore .

The use case is keeping track of changes that I make after installing an OS. Many of the changes are outside /etc, so I cannot just have /etc under revision control. And having / under revision control seemed very slow with git.

It seems that I can use a .gitignore as follows. To track, say, /usr/share/terminator/terminator :

*
!/usr
/usr/*
!/usr/share
/usr/share/*
!/usr/share/terminator
/use/share/terminator/*
!/usr/share/terminator/terminator

But this seems a bit clumsy (even if I were to auto-generate the .gitignore). Is there a better way (or a more appropriate version control system for this)?

1

There are 1 answers

5
Anshul Goyal On BEST ANSWER

I think you can use another work around for this with git. Note that git continues tracking a file even if it is in ignore rules, once it is already being tracked. So, assuming that you do not want to track new files very often,

  1. Add all the files that you actually want to track

    git add file1 file2 dir1/file3 dir1/file4 dir1/dir2/file5 dir2
    
  2. Commit these files using

    git commit -m "msg"
    
  3. Add an ignore rule to your .gitignore to ignore all other files

    echo "*" > .gitignore
    
  4. Now if you make changes to any of the existing files, they will show up in git status, git diff and so on. You can add them using git add filename and operate upon them normally.

  5. To add a new file next time onwards, you need to use -f

    git add -f new_file1 
    git commit -m "msg"