GreenOak
GreenOak

Reputation: 71

Is it possible to use git for tracking changes without storing them?

I have a big directory structure with lots of binary files (images) in it. I want to track which files were added/deleted/changed without actually storing the changes. Is it possible to do using git?

Just to reiterate, I don't care about the contents of the change, just want to register the fact that the file was added/deleted/changed.

Open to other suggestions besides git that work across Windows/Linux/macOS.

Upvotes: 1

Views: 666

Answers (3)

GreenOak
GreenOak

Reputation: 71

Inspired by @eftshift0 advice this is what I'm doing now (and it works well!)

  1. Exclude everything except my directory listing with .gitignore

     *
     !.gitignore
     !ls.txt
    
  2. Save list of files with modified dates into ls.txt (decided using date to track changes is enough for me for now, so not doing the checksum).

     find . -printf "%c %p\n" -iname "*.mov" -o -iname "*.jpg" -o -iname "*.mp4" > ls.txt
    
  3. Commit the listing

     git add ls.txt
     git commit -m "added some files"
    

PS Printing time with find actually can be quite slow (takes several minutes with my directory of about 10k files), so if you are tracking many files and you don't care about the modified date, better take it out. Could be just windows thing though (i'm using git bash on windows).

Upvotes: 1

eftshift0
eftshift0

Reputation: 30212

You could.... with some magic tricks outside of git, actually. Generate a list of all present files (with their checksums, be it sha1 or sha256 or md5) and put them in a file... add the file, commit.... then, after a while you do the same.... add, commit..... then after a while you do the same. So..... you could, by comparing the contents of that single file over different commits, know what happened, without actually storing the images themselves. Not too elegant, but it would work.

Upvotes: 1

matt
matt

Reputation: 535231

No. That is not, in fact, what Git is. It doesn't even know that any files were added/deleted/changed. It just takes snapshots of your actual project. Every snapshot contains all the files in the project. That is all that Git actually stores. You can't ask it not to do that; that's what Git does, period.

Upvotes: 3

Related Questions