Manage git repos in cloud-synced folders (Google Drive, Dropbox, OneDrive) without corruption.
When you store git repos in cloud-synced folders:
- Multiple machines modify
.git/simultaneously - Cloud sync causes corruption (dangling blobs, index conflicts, lock files)
git fsckshows errors, repos break randomly
Keep your working files in the cloud, but store .git/ locally on each machine:
~/GoogleDrive/dev/my-project/ ← Synced by cloud
├── src/ ← Code (synced)
├── .env ← Secrets (synced, gitignored)
├── .git-remote ← Remote URL (synced, gitignored)
└── .git ← Pointer file (synced)
↓
"gitdir: ~/.git-dirs/GoogleDrive/dev/my-project"
↓
~/.git-dirs/GoogleDrive/dev/my-project/ ← LOCAL (not synced)
├── objects/
├── refs/
└── ...
# One-liner install
curl -fsSL https://raw.githubusercontent.com/jgorostegui/git-cloud/main/install.sh | bash
# Or manual
git clone https://github.com/jgorostegui/git-cloud.git
cd git-cloud
./install.shInsync (Google Drive):
Account Settings → Ignore Rules → Add:
.git/
Dropbox:
echo ".git/" >> ~/Dropbox/rules.dropboxignoreImportant: Only ignore
.git/(directory), NOT.git(file). The pointer file should sync!
echo ".git-remote" >> ~/.gitignore_global
git config --global core.excludesfile ~/.gitignore_globalgit-cloud clone git@github.com:user/repo.git ~/GoogleDrive/dev/repoThis:
- Clones to
~/GoogleDrive/dev/repo/ - Stores
.gitin~/.git-dirs/GoogleDrive/dev/repo/ - Creates
.git-remotewith the URL (for other machines)
Files arrive via cloud sync, but no .git yet:
cd ~/GoogleDrive/dev/repo
git-cloud setupThis reads the URL from .git-remote and sets up git locally.
If you already have a repo with .git/ in your cloud folder:
cd ~/GoogleDrive/dev/existing-repo
git-cloud migrateThis moves .git/ to local storage and creates a pointer.
git-cloud statusShows:
- ✓ Properly configured repos
- ! Repos with
.git/directory (need migration) - ✗ Broken pointers (need setup)
- ? Folders with
.git-remotebut no.git
┌─────────────────────────────────────────────────────────────────┐
│ LAPTOP (first time) │
│ │
│ $ git-cloud clone git@github.com:me/project ~/GDrive/project │
│ │
│ Cloud syncs: src/, .env, .git-remote │
│ Local only: ~/.git-dirs/GDrive/project/ │
└─────────────────────────────────────────────────────────────────┘
│
▼ (cloud sync)
┌─────────────────────────────────────────────────────────────────┐
│ DESKTOP (after sync) │
│ │
│ $ cd ~/GDrive/project │
│ ⚠ Run 'git-cloud setup' to enable git │
│ │
│ $ git-cloud setup │
│ Reading URL from .git-remote... │
│ Done! │
│ │
│ $ git status │
│ On branch main │
└─────────────────────────────────────────────────────────────────┘
| Command | Description |
|---|---|
git-cloud clone <url> [path] |
Clone with local .git storage |
git-cloud setup [url] [path] |
Setup git for synced folder |
git-cloud migrate [path] |
Move existing .git to local storage |
git-cloud status |
Show all repos and their state |
git-cloud help |
Show help |
| Variable | Default | Description |
|---|---|---|
GIT_DIRS |
~/.git-dirs |
Where to store .git directories |
CLOUD_DIRS |
~/GoogleDrive:~/Dropbox:~/OneDrive |
Cloud folders to scan (colon-separated) |
Git supports storing the .git directory separately from the working tree using:
git clone --separate-git-dir=<path>for new clones- A
.gitfile (not directory) containinggitdir: /path/to/.git
This is a standard git feature, not a hack. The git-cloud tool just automates the workflow.
Run git-cloud setup to connect the repo.
Make sure you're ignoring .git/ (with trailing slash) in your cloud client.
The .git file (pointer) SHOULD sync - only the directory should be ignored.
This is normal if files differ from remote. Run git status to see what changed.
MIT