Do you know if there is a way to block committing to a local git repository? In my build environment, I'm running some git commands through it and it breaks if the user makes a commit during the build.
I would like to lock the repository while the build is in progress then unlock when the build is finished.
Thanks!
That is not a Git-compatible work-flow. If you want an SCM with locking, use something else with a centralized-repository model. Some SCMs that support optional locks include SVN, CVS, and RCS.
Unless you are using a shared repository configured with core.sharedRepository enabled, you should be pushing to a bare repository and running any continuous integration or build systems off a non-bare clone. By definition, any shared repository can have the working directory modified by anyone with the necessary permissions, so you shouldn't be using a shared repository if you need to ensure a stable working directory during the lifetime of some process.
There are certainly some use cases for the shared repository model. However, yours is not one of them.
You could certainly design your own scripts to abuse the shared-repository model. For example, you might use semaphore files (such as those created by lockfile from the lockfile-progs package) or flock in a wrapper script that turns off write or execute permissions on your shared directory before kicking off some long-running build process. That's a lot of work for a very small pay-off, since you could get the same benefit with less work with a clone. However, it is technically feasible, so I mention it here for completeness.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With