Search code examples
gitwindows-share

Do multiple instances of git operating on the same repository create problems?


My Employer just now is switching to git, so my cowokers are still somewhat inexperienced. What they did now, concerned me, so I'm writing this up.

They cloned a git repository on a machine, then shared that repository via windows share. Now, on the machines that the repository is being shared to, they work on it. This works surprisingly well, as long as no more than one person is working at the same time.

Nothing exploded yet, but I have a bad feeling about this.

What could go wrong? Or is this actually safe to do?

Before someone asks: They are doing this because that shared directory has scripts on it they dont want to copy to their machines. I tried talking them out of it, but they like the idea a lot.


Solution

  • If they all only ever read from this shared area, it's OK. (They must all stop reading while anyone updates the shared area.)

    Writing to shared areas is generally a bad idea, because:

    • two people could try to write to the same file;
    • one person could try to read a file while someone else writes it.

    There are systems that try1 to reconcile this sort of thing (e.g., Dropbox). Git is not one of them. Don't do it. (Don't put a Git repository in a Dropbox area either.)

    Basically, what happens when people do this sort of thing is that it works for a while, then it breaks and nobody can figure out precisely what happened.2 (This is the same thing that happens with programs written in languages that allow thread or other concurrency races.)


    1The word try is here for a reason: these systems always have some corner cases where they cannot be sure which version is the right "latest" version, and start doing things like turning file.ext into file.ext (1) and file.ext (2) and forcing the user to resolve the collision. Doing this to a crucial Git internal file (such as the file that holds the HEAD ref) will break a repository.

    2In some similar circumstances, I've been well-paid to figure out what happened and/or clean up the mess. As consulting gigs go, these aren't bad.