2

If two processes try to do something to a Git repository at the same time, is there a chance of corrupting the data? Or does Git have some sort of locking mechanism to prevent this?

More specifically, what happens if git fetch and git gc are run at the same time? If one of them fails, then that's a risk I can live with. But if the repo gets borked, then that's not OK.

Mike Baranczak
  • 8,291
  • 8
  • 47
  • 71

1 Answers1

0

Git repo's make a .HEAD.lock file when doing operations, However from testing your case of running git fetch and git gc at the same time it seems like this does not come into affect. I would proceed with caution when doing this.

Benjojo
  • 78
  • 5
  • Can you elaborate? How exactly did you test this, and what happened? – Mike Baranczak Feb 10 '14 at 20:44
  • Some operations make a `.head.lock`, I mainly know this because it bothers me greatly when I have SourceTree open and I try and commit from the command line, This mainly happens upon write actions. You can see this going wrong here http://stackoverflow.com/questions/9481735/git-recover-from-failed-rebase – Benjojo Feb 17 '14 at 11:22