GitHub commands

To clone a repository to a specific folder. Using Bash, cd into the folder you want the repo to be cloned into. Then on the GitHub webpage where your repo is, click the clone button, this will present you with a http address. Copy this and add it to the command:

git clone

Then make sure you cd into the newly cloned folder.
If you make any changes to code and want to commit them. Type in:

git status

This will show you the ‘branch’ you are on and if there are any changes that can be committed. If there are any files that have been created or modified then they will be displayed with a red font.
To add these files you type in:

git add

or if you have a lot of files to add and want to do it in one go, type in:

git add .

Next you have to ‘commit’ these files. To do that type in:

git commit -m 'type a descriptive message here about this commit'

If you haven’t given your email and name then at this point you will be asked to do so. The command are:

git config --global user.email "you@example.com"
git config --global user.name "Your Name"

If you were asked to give your email and name then after you do you will need to type in the git commit -m ‘message’ command again.

You can now type in the command:

git log

to see a list of your commits.

To push the commits to your GitHub repository type in:

git push origin master

If you haven’t logged into your account you will be asked to do so. Just type in your username and GitHub password and the files will then be pushed to GitHub.