A ten second into to using Git with GitHub

I have a couple of projects I’m working on, and I’ve got them setup in GitHub. I’m a git novice, but I’ll get there.

Clone the Project

To work with a project hosted at GitHub, you first need to clone it. From the GitHub website, you can find the clone URL. Under 'Code' just copy the HTTPS URL (click the two-squares icon that looks something like this: ⧉).

Then just clone it using git:

$ git clone https://github.com/WingedGeek/PHPHTMLTemplate.git

Keep it Updated

To make sure you have the latest version of the code from the GitHub repository, change into the directory (in this example, PHPHTMLTemplate), and use git pull:

$ cd PHPHTMLTemplate
$ git pull

Upload Changes

Once you’ve tweaked the code, add the changes to the local staging area:

$ git add --all
 
Make the changed state a commit, with an explanatory message:
 
$ git commit -m "Added an empty test file"

And push the changes back to the remote (GitHub) repository:

$ git push

Here’s where it gets fun. In order to push to the repo, you’ll need to log in. To authenticate, you’ll need your username, and a personal access token. (You can cache this token, to make life easier.) Use your username when prompted, and when asked for a password, paste in the personal access token:

$ git push
Username for 'https://github.com': WingedGeek
Password for 'https://WingedGeek@github.com':

Comments