I have a strange network connection that is unreliable sometimes. I will sometimes have to manually press a button every time I want a new TCP connection, which could take up to a minute to reset.
I occasionally use this connection for pushing/pulling git changes.
Most of the time, this works pretty well. I simply git push
through the connection and my changes go through in a single connection.
However, if there are pending changes on the remote that I don't realise are there, my git push
will be rejected and I will have to go through a git pull
and then another git push
, turning my one connection into three. I could do a git pull
every time to make sure, but then that usually means an extra connection where one wasn't necessary.
Visual Studio has a term for doing a pull and then a push: "Sync". I am aware that this is not a real git term, but I was wondering if there was a way to set up aliases in such a way that a pull and a push could be done in a single TCP connection. This would make my life much easier.
I am aware that I could keep the connection open using SOCKS, but every layer of networking is costly as this isn't the fastest connection to start with.
Git itself does not have a way to do this: it uses libcurl to open http or https connections, and runs ssh
to open ssh connections. For the git://
protocol it has its own code that uses the OS's socket layer, and makes a new socket. While libcurl can do persistent connections, it does that on a per-invocation basis, and each Git command starts a new invocation.
Still, a proxy / tunnel would do the trick. It's up to you to decide whether the extra overhead is worthwhile.