Is putting a Git workspace in a synced folder really a good idea?

i have all my git repos synced with syncthing, it works well. BT Sync and ownCloud have problems here.

if there are 100.000 small files in the repo, it may take some time to first syncā€¦

1 Like

Why does BTSync and Dropbox have problems but Syncthing doesnā€™t?

1 Like

Iā€™ve been doing this with SugarSync for years and it works great. Want to try it with Syncthing at some point, but my experience using SS is the only problem is if the object files get to be too large, as SS delays syncing them.

You can, and itā€™ll sync just fine, but you shouldnā€™t.

A Git repository is not like a collection of documents. In a collection of documents, each file is mostly independent so itā€™s easy to ā€œmergeā€ when one file has changed on one device and another file on another device. A Git repository on the other hand is made up of a bunch of files that should be internally consistent with each other. ā€œMergingā€ two Git repositories that have diverged cannot be done by just copying in the newest files from each - it must be done by understanding the contents, doing an actual merge with a new commit, etc.

So no, donā€™t. Use a central Git repository and push/pull from it, like Linus intended.Ā :)

3 Likes

I think youā€™re imagining multiple people collaborating on a single synced project. However, I think Philippe is talking about a different scenario: single user, multiple machines. At least thatā€™s what Iā€™m looking into.

For example, Iā€™m in the middle of implementing a feature on my desktop PC, and my project is a big uncompilable mess. However, I need to leave for a week now, and all I can take with me is my laptop. Would be nice to continue where I left off, right? Without either messing up commit history, or wasting time cleaning up the project, or syncing it manually, or, better yet, putting it on a thumb drive.

My main concern was that the repository could potentially get messed up, if something were to go wrong during a sync, but looks like git is implemented in such a way, that things need to go really wrong (as in ā€œomg my computer is on fireā€ wrong) for it to become corrupted (due to the fact that it rarely modifies its files, and mostly adds new ones instead).

2 Likes

Iā€™ve had git repositories mess up in a big way when thereā€™s just 1 of me using Syncthing. I never dug properly into why, but it did happen surprisingly regularlyā€¦

Just make a WIP commit (make it to a temporary branch if youā€™re that worried), and sync using the normal git mechanisms.

Thatā€™s odd, Iā€™ve read multiple reports of people using git with Dropbox / Google Drive / whatever for years, with no issues. Iā€™ll try anyway, will leave a reply, if something goes wrong.

2 Likes

Over in #git on IRC we specifically advise people not to put git repos in Dropbox because of reports of corruption. It seems Dropbox does not handle lots of small fast-changing files well.

Well, gotta know the exact circumstances, to be sure. I mean, I can imagine somebody trying to work on some synced project on two machines simultaneously, and running into problems because of that.

If Iā€™m careful, the sync process should always be a one-way overwrite. If itā€™s not, in fact, one-way, then how can I trust Dropbox / Syncthing / etc. with anything at all?

2 Likes

Iā€™m talking about single users. I donā€™t know the details and what exactly Dropbox was getting wrong, but something wasnā€™t right. When you have a single repo in Dropbox, you donā€™t have the multiple redundancy that git normally gives you, so once that one copy gets corrupted youā€™re screwed.

Iā€™ve enabled staggered versioning for 90 days on my server, that should help, I guess.

All my git repositories usually have a proper remote, unless Iā€™m in very early stages of a dev process, so it wouldnā€™t be a huge tragedy, if my repo were to go corrupt.

There are things which I care about more than I care about my projects, though, and it would be a real shame if they would disappear forever. This is why Iā€™m actually trying to sync everything now, so that I would have a copy of my precious data on several machines, just in case. And now Iā€™m reading all the horror stories about sync clients ā€œnot handling many small files too wellā€ and ā€œswallowing documents from time to timeā€ :smile:

Maybe Iā€™ll also setup a cron job on my intermediate computer, and do a snapshot of the synced folder every night or so.

1 Like

To be clear, I was specifically talking about Dropbox before. While I have seen git repo corruption with Syncthing, iā€™m not sure what caused that.

They do use similar algorithms (block hashing), AFAIK, so the same issues apply to both, Iā€™d assume.

Hereā€™s an interesting read: When Git on Dropbox conflicts ā€“ No problem

1 Like

Iā€™d probably summarize it to ā€œif you have to ask, the answer is noā€.

There are safe ways to sync git repos for sure, but you really need to understand how it works and know exactly what youā€™re doing. If not, youā€™re just playing fast and loose with your repo.

I donā€™t understand why youā€™d want to do this with git. One of the objectives of git is to be decentralized. Just make a branch called uncompilable_mess and then clone the repo on your laptop.

That way, you donā€™t have to worry. Git is designed to do this.

Okay, say, Iā€™m in a hurry, and I have 5 projects with uncommitted changes. One of them has a new config file with sensitive information in it (e.g. an API key), which isnā€™t in .gitignore yet, and since I donā€™t have time to cherry-pick, I just git add -A everything and push it to a public repo. This is just one harmful situation which couldā€™ve been avoided if I were using a synchronization tool (not to mention that itā€™s also automatic, so I canā€™t just forget to, say, commit 1 project out of 5).

1 Like

Seems that the topic have been pretty active recently :smile:

Just for you all to know everything is running smoothly since Iā€™ve been asking for help. Iā€™ve never had any problem so far for my usage and in my setting which is a bit specific:

  • The git repo is not very active (< 2 commits / push / pull a day)
  • Iā€™m the only user of the repo
  • Syncthing is NOT always running in the background; for conservative reasons, I only fire it up when I have to sync my computers before heading out or after getting back

Generally speaking Iā€™d advise not to push/pull/commit git repos while having Syncthing running in order to lower the synchronizations required. Iā€™ve got no objective reason to do so but it seems just more logical and clean.

My 2 cents.

2 Likes

Thanks for chiming in. Thatā€™s what I decided to do myself too. This is essentially a semi-automatic rsync, where a single button does everything :slight_smile:

2 Likes

Just an extra tuppence-worth.

Iā€™m a single user syncronising a (Linux) desktop computer with a (Windows) laptop. Iā€™m sometimes jumping between different branches in a repo quite quickly, which sometimes means a lot of files changing very rapidly.

Mostly Syncthing seems to cope really well with this, but I recently had a number of old (deleted, local) branches resurrect themselves. I donā€™t know if this was Syncthing or not, but I have added .git to my .stignore just in case.

What I lose is having any purely local branches syncronised between the two machines, but I donā€™t really need that, and I donā€™t like having to try to remember which branches I had or hadnā€™t previously deleted!

3 Likes

This topic was automatically closed 29 days after the last reply. New replies are no longer allowed.