task: task-1753636924-a1d4c708 - created

Change-Id: Ic78528c47ae38114b9b7504f1c4a76f95e93eb13
diff --git a/server/git/mutex.go b/server/git/mutex.go
new file mode 100644
index 0000000..21bc25f
--- /dev/null
+++ b/server/git/mutex.go
@@ -0,0 +1,40 @@
+package git
+
+import (
+	"sync"
+)
+
+// GitMutex provides thread-safe access to Git operations
+// Since Git is not thread-safe, we need to serialize all Git operations
+// across all agents to prevent repository corruption and race conditions
+type GitMutex struct {
+	mu sync.Mutex
+}
+
+// NewGitMutex creates a new GitMutex instance
+func NewGitMutex() *GitMutex {
+	return &GitMutex{}
+}
+
+// Lock acquires the Git operation lock
+// This ensures only one agent can perform Git operations at a time
+func (gm *GitMutex) Lock() {
+	gm.mu.Lock()
+}
+
+// Unlock releases the Git operation lock
+func (gm *GitMutex) Unlock() {
+	gm.mu.Unlock()
+}
+
+// WithLock executes a function while holding the Git lock
+// This is a convenience method to ensure proper lock/unlock pattern
+func (gm *GitMutex) WithLock(fn func() error) error {
+	gm.Lock()
+	defer gm.Unlock()
+	return fn()
+}
+
+// Global Git mutex instance - shared across all agents
+// This ensures no concurrent Git operations across the entire application
+var GlobalGitMutex = NewGitMutex()
\ No newline at end of file