User Tools

Site Tools


tutorials:4

This is an old revision of the document!


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 username@tardisproject.uk:~/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/ username@tardisproject.uk:~/my_code
  • -ravP is equivalent to -r -a -v -P
  • -r means recursively - do all the directories
  • -a means preserve permissions, etc. on the other side.
  • -v means print out some extra information, and P means show progress
  • my_code/ is our source, and our destination is username@tardisproject.uk:~/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:

We run an instance of GitLab, which can host private or public repositories for you. You can login to it here, and learn about it https://docs.gitlab.com/ee/tutorials/.

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.

tutorials/4.1680526258.txt.gz · Last modified: 2023/04/03 12:50 by tcmal