Table of Contents
4. Moving files around
Right now we've just been making files using the terminal, but eventually you'll probably want to edit files on your local machine and push them up, or vice versa.
There are many ways to do this, but we'll just focus on the simplest here.
One-off / Big files
If you just want to transfer one file quickly, use
scp (secure copy):
scp big-file.zip firstname.lastname@example.org:~/where/it/should/go/big-file.zip
Entire directories (the lazy way)
If you have a whole directory with code or whatever else, then it's likely
rsync will be faster - it's a lot more complicated but is designed to only transfer files that have changed. Here's an example command you could use:
rsync -ravP my_code/ email@example.com:~/my_code
-ravPis equivalent to
-r -a -v -P
-rmeans recursively - do all the directories
-ameans preserve permissions, etc. on the other side.
-vmeans print out some extra information, and
Pmeans show progress
my_code/is our source, and our destination is
firstname.lastname@example.org:~/my_code. The part after the colon is the path, and
~expands to our home directory as usual.
Unlike most programs, a trailing / in our destination actually makes a difference - if we had
~/my_code/ then it would create a directory named
my_code, and place our entire directory under that, giving us
~/my_code/my_code/…. Without a trailing /, we just mean the new name of the directory is
~/my_code, so we don't have the two levels.
Entire projects (the proper way)
If your project isn't just a one-off script, and especially if you're working with other people, you most likely want to properly keep track of what's changed and where all your files are. The most common way to do this is a software called
git. It can:
- Keep track of all the changes you've made to a file, and see exactly what's changed
- Use this information to efficiently push/pull to different machines
- Merge changes multiple people have merged into a new version
You can learn about Git here:
Once you have a GitLab repository setup, you can just clone/pull the repo to wherever you're working on - whether that's on Tardis or not.
GitLab can also do much more things, like track issues, run tests and deploy for you automatically, let others submit changes for review, and a lot more.