Command line Git

Using git from terminal is very easy and it will give you a lot of control and freedom!

Download

Git cheat sheet

Moving through your folders

Before executing any git commands, make sure you are in the folder you want your code to be into

Moving through your folders is very easy

Type ls to see all the files in the folder you are in now

Type cd folder_name to go into a folder

Type cd .. to go out of the folder to its parent one

Cloning your repository

After you have created your repository on Github, you should clone it in your computer to make changes to your code

git clone https://github.com/your_name/your_repo_name

Uploading your changes to Github

Once you have made your changes, you will want to upload them to Github. To do this, you should follow these super easy three steps

First, you need to tell git which files you want to upload. For each file you want to add, you will need to do this:

git add file_name

Alternatively, if you want to add all the files in the folder you are in you can type

git add .

However, you wanna be careful! There may be files you will not want to upload such as password files or binary files. Check this with your mentor

When all your files are added, you will want to group them in a commit. A commit groups your files and specifies which changes they correspond to

git commit -m "Message explaining what you have done"

Now your changes are grouped together and changed in your computer, but they are not up yet. To put them up you will need to code git push

Amending an error

Great! Now your changes are up. Oh but you forgot to upload a file or make a change! No worries. Go back to make your changes and add your files as before using git add file_name

When you have done this, instead of creating a new group of files, you can do git commit --amend

This will change your previous commit instead of creating a new one

Now you can upload it again doing git push