Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there anything wrong with using git like this?

Tags:

git

rsync

Here is my situation. I keep a set of files on both my laptop, and a server. I already have a sync setup between the two locations using rsync. Recently I decided that a certain part of these files should be under source control. I am using git for this.

So I have shared/ which I sync using rsync. Then I have shared/stuff/ which is under git control. I will be using git from both locations on the repository that is local. I only work with one copy at a time, and I always sync the files back and forth.

I am the only person dealing with these files, and these two locations are the only places these files exist. The only reason I have git is because just today I accidentally deleted some code, and couldn't get it back.

So my real question: does rsync do anything that will break git? Or vice-versa?

Edit: For those that are curious, the reason I am using rsync to sync instead of git, is because I already have a great system for keeping the shared/ folder synced, and would like to keep the git repository in it.

like image 395
Mike Cooper Avatar asked Dec 21 '25 14:12

Mike Cooper


1 Answers

There is nothing wrong.

Remember that git objects: commits, trees and blobs are immutable, so a git object storage is like a log, you only write new objects to it without removing anything, even when you "rewrite history". Not before git gc do you stop the world and prune. Git makes it hard to lose data.


If your repository is very big, and you repack it, rsync has to transfer the whole object database again, since git packs everything into a new, big pack file. If you want to repack, you can either use git repack instead which will create new packs for new objects without touching the old. Or you can repack once good, and mark the big pack file for keeping:

If you have a pack file called .git/objects/pack-fe017c0e9ea12841cd29458df7bd4421c2b12458.pack, just create one named .keep beside it:

touch .git/objects/pack-fe017c0e9ea12841cd29458df7bd4421c2b12458.keep

Now, git gc won't rewrite that pack file, but it will take all other small packs and objects and collect them together. The difference to git repack is that you won't build up a collection of lots of small pack files.

like image 150
u0b34a0f6ae Avatar answered Dec 24 '25 04:12

u0b34a0f6ae



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!