I currently have a development laptop at home and a PC in the office. The application I develop runs at the PC because it requires specialized hardware.

Because the application is sort-of-a monolith, I cannot easily replace/upgrade a single application component via a CI/CD pipeline. The most comfortable solution is to push the code directly to the PC, build the component there and then launch it for debugging.

Adding a PC as a remote repo is easy. Let’s use a ssh connection.

On Laptop
git remote add pc ssh://username@mypc_ip:/home/username/workspace

Now, when I try to push to the remote PC, I might get rejected. There is a non-bare repository, which is not a big problem in my conditions. I can push into a non-bare repo. However, I have the same branch checked-out at the remote machine because I build the branch there.

One possible solution is to have a script that checks out some other branch on the remote machine, then pushes and then checks out the original branch. It works but it is obnoxious.

Fortunately, git allows to push to a checked-out branch. Here is how to do it:

On PC
git config receive.denyCurrentBranch=updateInstead

And that’s it.