// Tutorial //

How To Fork, Clone, and Push Changes Using Git and GitHub

Published on December 12, 2019
Default avatar

By Denis Murphy

How To Fork, Clone, and Push Changes Using Git and GitHub

This tutorial is out of date and no longer maintained.


GitHub is an excellent resource for finding useful code. In order to contribute changes back to a project, you’ll need to make a local copy and then upload your changes. In this tutorial, you’ll fork and clone an existing repo, and then make changes to your local copy of the repo and push them back to GitHub.

Fork and Clone

Go to the Skeletonwebsite repository on GitHub and click on Fork.

Screenshot of the fork button on GitHub.

Fork will create a copy of the repository in your GitHub account so that you can make changes to the project.

Go to your own GitHub repository and you will see a repository named skeletonwebsite.

Click into this repository and we will now make a local copy of it on your machine by hitting the clone button.

Screenshot of the clone or download dialog window on GitHub.

Copy the HTTPS URL.

Open your terminal or git bash window.

Move to the location on your computer where you want to create a copy of this project.

Run the following command:

  1. git clone https://github.com/userid/skeletonwebsite.git

Note: Substitute your GitHub username for userid.

You now have a local copy on your computer.

The folder on your computer will have the same name as the remote repository on GitHub, skeletonwebsite

Change to the project directory:

  1. cd skeletonwebsite

Initialize git:

  1. git init

Screenshot of the hidden git folder in the project directory.

After running git init you should see a hidden git folder in your skeletonwebsite directory. If you don’t see it, change the settings on your computer to show hidden files and directories.

To see the current status of your local repository, run:

  1. git status

This will show if you have any commits that are staged or committed.

Open up the index.html file in your code editor.

Add a heading or a paragraph.

Check the current status with changes applied:

  1. git status

You should see that there are changes not staged to be committed with the index.html file in red.

Screenshot of the project status, with the index file indicated as modified and not staged.

We will now add this change by running:

  1. git add index.html

If you want to add multiple files at once then you can run git add .

Run git status:

Screenshot of the project status, with the index file indicated as modified and staged.

Changes have now been staged and are ready to be committed.

Now we can run git commit to commit these changes.

Use the -m flag to add a commit message.

Remember to describe the specific change you made in the git commit message.

  1. git commit -m "added heading to index.html file"

Screenshot of the commit message.

To check that everything is up to date, run:

  1. git status

Screenshot of the project status, with nothing to commit, the working tree is clean.

This message shows everything is up to date.

We can now push our code to our repository on GitHub.

Before we do this, see what remote repository on GitHub our local repository is connected to:

  1. git remote -v

Screenshot of the configuration for the remote repository.

Push Changes

To push our changes to this repository, run:

  1. git push origin master

Screenshot of the changes pushed to GitHub.

Check that your remote repository has been updated on GitHub.

Screenshot of verifying the project being updated on GitHub.


In this tutorial, you have successfully:

  1. Forked a repo.
  2. Cloned it to create a local repo on your computer.
  3. Made a change to the index.html file.
  4. Staged this change.
  5. Committed this change.
  6. Confirmed what remote repo your local repo is connected to.
  7. Successfully pushed your code to your forked repo on GitHub.

Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.

Learn more about us

About the authors
Default avatar
Denis Murphy


Still looking for an answer?

Ask a questionSearch for more help

Was this helpful?
Leave a comment

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

card icon
Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Sign up
card icon
Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We’d like to help.

Learn more
card icon
Become a contributor

You get paid; we donate to tech nonprofits.

Learn more
Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow – whether you’re running one virtual machine or ten thousand.

Learn more ->
DigitalOcean Cloud Control Panel
Get started for free

Enter your email to get $200 in credit for your first 60 days with DigitalOcean.

New accounts only. By submitting your email you agree to our Privacy Policy.

© 2023 DigitalOcean, LLC.