Image
Top
Navigation
January 26, 2017

Tutorial: How to get setup on GitHub

…or rather “How to git setup on Github”? Ok I’ll let myself out. But first I’ll finish writing this tutorial.

Pretty exciting because I finally got to learn some Git today, and just created my first repository on Github. My first repo is on that dear weather app I created back in November. I submitted it as a Term 2 portfolio piece, and have received some pretty great feedback from my classmates. According to my Github account, February 2nd was when I first started my web development training on Free Code Camp. Pretty cool! Can’t believe it’s almost a year.

Here’s a step-by-step tutorial on how I would create a Git repository on GitHub.

STEP 1

YOU WILL WANT TO DOWNLOAD THE FOLLOWING:

Homebrew – Install this so you can install Git
SourceTree – To interact with Git

HOW TO INSTALL HOMEBREW:
  1. Go to the Homebrew website
  2. Open up your Terminal
  3. Copy and paste their Install Homebrew line of code into your Terminal and hit enter
  4. Follow the download instructions on the command line to finish installing Homebrew

STEP 2

INSTALL GIT

On the command line, type:

brew install git

 

Once Git is done downloading, you can double-check to make sure that it’s fully installed. One way to check is by pulling up the version of git that you have. To do so, you can type the following to the command line (there are 2 dashes before version):

git --version

 


STEP 3

Create a workspace directory inside your home directly. You can name it whatever you like but I called mine “workspace’. Once you’ve got a directory in there, put your project directory inside the workspace directory.


STEP 4

CHANGE YOUR WORKING DIRECTORY TO YOUR PROJECT 

I like the initialize my repository inside the command line and then open it up in SourceTree. To do so, you’ll want to type the following:

ls

 

This will list all the files inside the user directory.

Next, you’ll want to change the work directory to your project. Since my file name is js-project (for demo purposes), this is what I did:

cd workspace/js-project

 

cd stands for change directory and will access the contents of the workspace directory. Typing cd workspace in the command line is basically the same as double clicking the workspace directory.

When you are done this step, don’t close your Terminal yet because you’ll need it later.


STEP 5

OPEN AND SETUP SOURCETREE

Go through the setup which includes creating an Atlassian account. After that, connect SourceTree to your GitHub account.

You’ll want to add a repository under the local tab. You can do that by dragging your repository to SourceTree. Once your files are added, head over to your GitHub account. You should be able to see that repository on your profile.


STEP 6

SETUP YOUR REPOSITORY

Click into your repository on GitHub and you should see a setup guide. I like to create a new repository on the command line. To do so, you copy and paste each line of code given to you from GitHub that pertains to your files.

echo "# js-project" >> README.md

Echo is a command-line command to print on the screen >> README.md means it’ll re-direct that output to a file, and creates that file.

git init

Git init pretty much means “I want to track the files in this directory.”

git add .

-m "first commit"

git remote add origin https://github.com/user/js-project.git

git push -u origin master

Once you have copy and pasted the code, you’ll be prompted to sign in to GitHub on Terminal.


STEP 7

Take a look at your repository on GitHub. It now has all the documents plus a README.md file. Be sure to include a short and meaningful description of your repository.

The README.md file allows you to put a longer and more detailed description of your repository. You can include whatever you like to supplement on there.

You are pretty much done here. To make or update any changes, you can do so through SourceTree.

Update/make changes through sourcetree
  1. Open up your repository on a text editor and make your changes.
  2. On SourceTree, you should see Uncommitted Changes showing what has been added and deleted.
  3. Click on the Commit (+) button and enter your user details.
  4. Write a meaningful description of what changes you have made.
  5. Check the box next to “Push changes immediately to origin/master” and click Commit.
  6. Refresh the repository on GitHub and you should be able to see the change comment.

Submit a Comment