For a current course I am taking, we are using a remote computer to run our code.
I am coding locally on my MacBook and I'm looking for a good way to keep my local code up to date on the cluster.
The way I was doing it was to have a terminal open for running SCP to copy the directory, and another terminal that was SSH-ed into the cluster for making and running my code.
This seems less than optimal for me. Is there a way that I could automate the sending of the files to the cluster when they are modified?
Or am I stuck with the one-line command to move everything?
In VS Code, select Remote-SSH: Connect to Host... from the Command Palette (F1, Ctrl+Shift+P) and use the same user@hostname as in step 1. If VS Code cannot automatically detect the type of server you are connecting to, you will be asked to select the type manually.
rsync works in one direction, so we need to run it twice to sync directories in both directions.
Your best option, other than a distributed version control, is using rsync over ssh. I keep a couple of machines in sync by doing the following on each one:
rsync -urltv --delete -e ssh /src.dir user@othermachine:/src.dir
You mentioned using a MacBook - rsync is on Mac OS X. As far as I know, it didn't need to be installed extra. And the beauty of rsync is that it looks for modifications and only copies modified files over. It doesn't do merging of simultaneous modifications like a distributed version control system would, but if you're like me where you do some work on your laptop then some work on your desktop, rsync is the best way to send all the changed files (and only the changed files) from one to the other when you switch modes.
Note: the rsync options used here are:
-u
, --update skip files that are newer on the receiver-r
, --recursive recurse into directories-l
, --links copy symlinks as symlinks-t
, --times preserve modification times-v
, --verbose increase verbosity--delete
delete extraneous files from dest dirs, acts as --delete-during
lastly, -e
is the option that allows you to specify your remote shell, in this case ssh
If you can use rsync, that would probably be the best way.
Would using sshfs to (fuse) mount the remote folder(s) be an option? You could either edit the files directly, or use rsync, unison or any folder to folder synchronisation tool then.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With