Developing with Git and GitHub for Beginners

Updated by Linode

Contribute on GitHub

View Project | View File | Edit File

Git is a file tracking application, or version control system. GitHub is a website that allows collaboration between developers who use Git. With Git and GitHub, programmers from across the world can share ideas and code in an organized and up-to-date process.

Install and Configure Git

The directions below are for Debian or Ubuntu. For installation on Mac, Windows, or other Linux distributions, find instructions in the Git Source Control Management guide. While that guide focuses on Git, this guide focuses more on Git with GitHub.

  1. Install:

    sudo apt-get update
    sudo apt-get install git -y
  2. Configure the username, replace First Last:

    git config --global "First Last" 
  3. Configure the email, replace

    git config --global ""

    Now that Git has been installed, refer to the image below for help with using Git and GitHub together.

    Workflow for using Git with GitHub.

Clone a Test Repository

A repository, or repo, is a Git project. For tutorial purposes, there is a test repository setup on GitHub, which is listed below.

  1. Go to the GitHub homepage. At the top, search for test-repo-789. If you would like to contribute to Linode’s guides, search for linode docs.

    GitHub homepage search.

  2. Select test-repo-789, it should be the first result, listed as AccForTesting1/test-repo-789.

  3. Copy the “HTTPS clone URL” link using the clipboard icon at the bottom right of the page’s side-bar, pictured below.

    GitHub clone clipboard.

  4. In the Linode terminal from the home directory, use the command git clone, then paste the link from your clipboard, or copy the command and link from below:

    git clone
  5. Change directories to the new ~/test-repo-789 directory:

    cd ~/test-repo-789/
  6. To ensure that your master branch is up-to-date, use the pull command:

    git pull master

Create a GitHub Account and Fork the Test Repo

To share new files or file revisions, you’ll need a GitHub account and a project fork. A fork is a copy of a repo held on your GitHub account.

  1. Create a username on GitHub. At the “Welcome to GitHub” page, select the green, “Finish sign up” button at the bottom.

  2. Select your username at the top right of the page, pictured below, which links to your profile.

    GitHub username icon.

  3. To fork test-repo-789, use the search bar at the top left of the page. Search for test-repo-789.

  4. After you select AccForTesting1/test-repo-789, fork the repo using the “Fork” button on the top right of the page. The “Fork” button is under the username icon pictured in step 2 above.

    GitHub Fork Button.

You now have a copy of the repo on your GitHub account. Next, return to the terminal of the development Linode.

Push to the Forked Repo

Create files on the development Linode and push them to the forked repository on GitHub.

  1. From the ~/test-repo-789 directory, create and checkout a new branch:

    git checkout -b newbranch 
  2. Create a project directory:

    mkdir project
  3. Create sample files:

    touch repoTest1.js repoTest2.htm project/prjtTest1.js project/prjtTest1.htm
  4. Check the status of the Git project, with the git status command:

    git status
    # On branch newbranch
    # Untracked files:
    #   (use "git add <file>..." to include in what will be committed)
    #       project/
    #       repoTest1.js
    #       repoTest2.htm
    nothing added to commit but untracked files present (use "git add" to track)
  5. Add all the files in ~/test-repo-789 to the Git staging area:

    git add . 

    To add only one file, replace the period above with the full directory path and filename.

  6. Check the status again with git status, then commit the files to the Git project:

     git commit -m "Test files for test-repo-789 fork"
  7. Push the new files to the forked repo on your new GitHub account. Replace SampleUser1234 below with your own GitHub username, and replace the repo name with the appropriate repo name if different:

    git push newbranch

    If you’ve configure two-factor authorization (2FA) on this account, you will need to push over SSH. See GitHub’s guide on Generating SSH Keys.

Create a Pull Request Against the Original, Previously Cloned Repo

So far, Git was installed on a development Linode, a repo project was cloned to that Linode, a GitHub username was created, and a repo fork was copied to the GitHub user account. The final step is to ask the original repo project to accept the new revisions or sample files. This final process is called a pull request.

  1. From the GitHub browser window, select your username from the top right of the page, pictured below.

    GitHub username icon.

  2. At your GitHub profile, select the test-repo-789 in the center of the page, pictured below.

    GitHub popular repositories.

  3. At the test-repo-789 page, select “branches”.

    GitHub branches.

  4. Under “Your branches”, select “New pull request”.

    GitHub branches.

  5. Check that the branch filters are set correctly.

    GitHub branch filters.

  6. Select the “Create pull request” button.

    GitHub branch filters.

Congratulations, you have used Git and GitHub for file sharing and version control. There are still many Git commands to learn, but you are off to a great start.

More Information

You may wish to consult the following resources for additional information on this topic. While these are provided in the hope that they will be useful, please note that we cannot vouch for the accuracy or timeliness of externally hosted materials.

This guide is published under a CC BY-ND 4.0 license.