This article is now published on my website: A one-off git repo server.
Last active
April 21, 2023 07:33
-
Star
(140)
You must be signed in to star a gist -
Fork
(27)
You must be signed in to fork a gist
-
-
Save datagrok/5080545 to your computer and use it in GitHub Desktop.
How to easily launch a temporary one-off git server from any local repository, to enable a peer-to-peer git workflow.
Nice. However you still have to expose your port.
I rather use git bundle
as described here: https://git-scm.com/blog/2010/03/10/bundles.html
It also solves the issue when you do not want to be online at the same time.
For anyone wondering why simply running a http server in the repo directory is a bad idea: you have to ensure the repo is "packed" at all times by periodically running git repack
, otherwise the clients will get some random old state of the repo
A new built-in command git-serve
was added in Git 2.18, so the alias "serve" no longer works. Changing the alias to "server" is a simple workaround.
404 Not Found
nginx/1.18.0
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is awesome for local development and test servers
Note: The default git port is 9418.
Consider
git daemon
running, you cangit clone git://localhost/ ~/src/new_copy
just like you wouldgit clone ~/src/original_copy ~/src/new_copy
.git clone git://192.168.1.123/ local-repo-name
as Datagrok said.What about a remote server that you have to SSH to? (maybe even using VPN or a bastion, etc.)
-R 9418:localhost:9418
to the command.ssh -R 9418:localhost:9418 [email protected]
ssh -o 'ProxyCommand ssh -W %h:%p bastion.int' -R 9418:localhost:9418 [email protected]
git clone git://localhost/ local-repo-name
on the server, and it is talking to your local workstation via a Reverse Tunnel.Tunnels are amazing! Anything must be possible!
Surely your partner at Starbucks (from #2 above) ought to be able to clone from you if that was possible.
-L 9418:localhost:9418
to the command.ssh -L 9418:localhost:9418 [email protected]
git clone git://localhost/ local-repo-name
on her workstation, and it is talking to your workstation via a Forward Tunnel… that's pointed at the Reverse Tunnel from #4Read those checkbox bullets over and over again out loud until it sticks. When you are able to conjure SSH Tunnels without Googling or searching
man
pages, you will never look at "connection issues" the same way again.