Local git repo for remote code syncing

Helpful while non of other options works

There are multiple way to edit and commit file on a remote host, like VSCode, Jetbrains Sync. But sometimes these may not work for your case. For example:

  1. The host SSH-able does not connect to internet, so can’t do git pull.
  2. Glibc version too old for VSCode.
  3. Private repo not public available.

In these cases, one way to make it work is to use a local git repo on remote host, and push to it use SSH. (For example, below I use a private LustreSrc package I’m working on.)

On target host

1
2
3
mkdir -p ~/git-repos/lustreSrc.git
cd ~/git-repos/lustreSrc.git
git init --bare # this initialize the local git repo

On local git repo, which you should have already cloned it locally, add a remote target on host.

1
2
git remote add mdstest mdstest:/home/$USER/git-repos/lustreSrc.git
git push -u mdstest b2_15 # <branch_name> you want to work on

On target host

1
2
3
git clone ~/git-repos/lustreSrc.git
git checkout b2_15 # Checkout <branch_name> specified above
git pull

Then you are all set to do bi-directal sync between local and remote! Just push and commit as usual.

Licensed under CC BY-NC-SA 4.0
comments powered by Disqus
Built with Hugo
Theme Stack designed by Jimmy