# Skolo Cheatsheet

Quick, easy to follow commands for web development, python programming, linux development, working with git. Take what you need 🎉 💯

# Moving Files RSYNC

Rsync is a quick and convenient way to move files between virtual server and personal computer. If you have big group of files, want to skip git and just move stuff around.

Say we want to move a file on our desktop (Use absolute paths to files) in to a VPS with a IP address and username

rsync -avz /Users/username/Desktop/filename.ext zatosh@xx.xx.xx.xx:/home/username/path/to/location/

# Git Pull

Use this when you want to move files from a VPS to your personal computer with git. You would need git installed on both computers. In the VPS - Other computer you are pulling from:

git init

You will get feedback like this

Initialized empty Git repository in /home/username/test/.git/

You know Git was initialised properly, copy that absolute path to the .git in my case its:

/home/username/test/.git/

You then need to add files to git and commit, so you have something to pull later on:

git addd .

git commit -m "initial commit"

In your personal computer:

git init

Then add the remote repo:

git remote add upstream username@xx.xx.xx.xx:/home/username/test/.git/

Adding the repo includes the add command, and the remote location. Keep in mind when you created the repo from the VPS you copied that absolute path to .git - that is the same path you are adding to the IP address of your VPS.

If all is well, you should be able to:

git pull upstream master

And you will pull all the files in the remote repo. If you need to remove the remote repo:

git remote rm upstream

# Git Push

Use this when you want to move files from your personal computer to VPS, as you make changes and you need to push chages to a remote repo.

Inside of your VPS: Create a bare repo, not inside your current repo. So cd out of the location where the git repo is, where the files are that you want to push to.

cd ..

You should now see your working directory if you do

ls

Create a new directory called repo

mkdir repo && cd repo

Inside the repo directory, before running these command, take note of your current absolute path to the repo folder and absolute path to the working directory folder - you will be pushing to. Then run:

To initiate bare repo.

git init --bare

Open the post-receive

sudo nano hooks/post-receive

Paste this inside

#!/bin/bash
git --work-tree=/home/username/test/ --git-dir=/home/username/repo checkout -f

This assumes the working dir is: /home/username/test/ and the repo --bare directory with is at: /home/username/repo Close the file and run:

sudo chmod +x hooks/post-receive

WARNING

This is very important, do not forget to run the above command.

Inside your personal computer, you need to add the remote repo. Note we are calling this "origin" not "upstream" as before.

git remote add origin username@xx.xx.xx.xx:/home/username/repo

Remember the absolute path to your --bare repo folder.

After this all you need is, add items to your local .git and then push them like so.

git add .

git push origin master

You can remove remote repo

git remote rm origin