Reading Time: 2 minutes
GitHub is a free repository hosting service, used as version control for web developers to download and push their code from their servers to other users. In our previous article we’ve instructed on how to add Git to your Ubuntu VPS server
. We’ll continue on and show you how to add and clone a repo from GitHub to your server.
Step 1: GitHub Account Setup
If you haven’t done so already, make a Github.com
account, it’s free! This is where you’ll be creating a repo and putting in files. Once you’re in your HubSpot account, click Create a repository (
or New Repository
), which will take you to a page where you can add details for your repo.
Step 2: Create Repo via Browser
Fill out the details for your repo and be sure to take note your repo name, you’ll need it later in this tutorial. If you are curious about the options on this screen, the README file is common for writing instructions to your users. The licensing option can seem confusing but if you are questioning which one to choose you can check out this site to guide you
. Once all details are in, click Create repository
Once created, you’ll see two files in your repository if you chose the licensing
Step 3: Configuring Git per User
After installing Git, configuration is needed for commit messages to be sent out. Without setting the name and email address you’ll see warnings when making commitments to git. If you have multiple user who utilize git, make an entry for each user. You can easily set these details for a user with two commands within your server’s terminal. (If you need to access the information set you can find it in the .gitconfig file.)
If you already have a github.com account you can use the associated username and email.
git config --global user.name "Your_Name"
git config --global user.email "email@example.com"
Step 4: Create A Directory
When you create a directory, you can use this space to sync newly written/edited code to your GitHub account. I’m going to call this environment git_environment
and move into the directory using the cd command.
Step 5: Copy your GitHub URL
First, its necessary to clone or download our already pre-existing README and licensing file from our GitHub account. Jump back to your GitHub account, click Clone or download
and copy your GitHub link.
Step 6: Clone your Repo
In your terminal, you should find yourself in the GitHub directory. We will first clone our repo with our copied GitHub URL and then change directories to our project name.
git clone https://github.com/username/want-some-java.git
By listing the want-some-java
directory, you’ll see the two files in your repo, verifying that the cloning has worked.
In our next tutorial, where will teach you how to edit/create a file on your server and push the script to your GitHub account.