What's the purpose of this? I don't get it. Why push at all to "local remote", if you can just keep your changes on a local branch, and push it whenever "remote remote" becomes available again?
A "local remote" is a contradiction. Unless the remote is on a different disk you are just wasting space. Even then the point of remotes is for sharing, not for backup/redundancy.
you can also setup a local remote which hardlinks the index so it doesn't occupy more space. Why? Idk. You don't want to share stash, rerere-cache, branches whatever.
Also handy if you're running an agent in a container on the local fs. Set up a local clone, contain the agent to that repo folder and have it hack away on that. Later, you step out of the container and do the syncing. You can't use worktrees in this situations.
Bare repos are also pretty cool. You can clone the git mailing list as a bare repo and search for threads there instead of setting up an mbox (same for the kernel obviously)
You can also have multiple independent git repos that don't duplicate the full object store, via git clone --reference. It's less relevant in the container era, but otherwise it can save a lot of time and disk space when cloning repos repeatedly
I was expecting the use of non-SSH git remotes without network access. Any mounted file system can be a valid remote such as a USB drive. I use file-based remote to keep some repos encrypted on S3 using Rclone.
For example, `git remote -v` would show:
`secure-s3 /mnt/fuse/rclone/secure-s3/git/$REPO.git`
I think concurrency is a problem with file-based remotes but for one person keeping a desktop and laptop in sync it is much simpler than running a VPS.
I love reading articles like this. It's kinda of a slap in the face – "hey guys, you know that thing you've been doing for decades, well for decades you've had this ability to do it with your own stuff if you just spend a few human brain tokens on it".
Sometimes I do this if I want to cherry pick commits from another repo already on my machine. Add the other repo as a local remote and then I can "import" that code while keeping its history in the new repo.
In my experience, local remotes shine when you have multiple clones of the same repo on the same machine (e.g., different working trees) and you want to share objects without re-downloading or using symlinks. Also, for quick offline backups: `git push /mnt/backup/repo.git --all` is dead simple. To answer mystifyingpoi's question, one reason to push to a local remote is if you want a separate copy that isn't affected by your branch naming—or if you're using multiple clients (like a work and personal repo) that need to sync when network is available later.
18 comments
[ 3.4 ms ] story [ 49.6 ms ] threadAlso handy if you're running an agent in a container on the local fs. Set up a local clone, contain the agent to that repo folder and have it hack away on that. Later, you step out of the container and do the syncing. You can't use worktrees in this situations.
Bare repos are also pretty cool. You can clone the git mailing list as a bare repo and search for threads there instead of setting up an mbox (same for the kernel obviously)
For example, `git remote -v` would show: `secure-s3 /mnt/fuse/rclone/secure-s3/git/$REPO.git`
I think concurrency is a problem with file-based remotes but for one person keeping a desktop and laptop in sync it is much simpler than running a VPS.
btw, Git also supports the HTTP protocol ...
> A related trick worth knowing — one git push can fan out to two destinations:
git remote set-url --add --push origin ~/bares/<repo>.git # add a 2nd push URL # now `git push origin` writes to GitHub AND the local bare repo