How to archive or zip a folder with a command line so you can transfer it

I had to figure this out myself and thought I’d share what I’m doing.

Make an archive:
tar -cf TargetFile.tar Foldername/
The c flag tells it to create an archive.
The f flag tells it that you’re making an archive from files.

Compress it:
gzip TargetFile.tar

And the resulting file is:

TargetFile.tar.gz

If you want real good compression and so on, you’ll need to play around with the flags, but this will do when you simply need to transfer quickly. I tested on a big folder of about 250MB, the .tar file was 285MB and the resulting .tar.gz file was 211MB.