How to Commit and Push Changes from Ubuntu 18.04 to GitHub

Reading Time: 3 minutes

In our previous tutorial, we showed you how to create and sync a GitHub repository to your Ubuntu VPS server.  Using the last tutorial as a springboard, we’ll continue on and show you how to commit changes to GitHub. Specifically, we will push a script from your Ubuntu server to your GitHub account from the terminal.

Step 1: Create a File

After we SSH into our server, open a terminal and cd into the folder we created in the previous article. In this folder, we will create a simple JavaScript program.

public class HelloWorld {

    public static void main(String[] args) {
        // Prints "Hello, World" to the terminal window.
        System.out.println("Hello, World");


Step 2:  Checking our New Script's Status

Next, using the following command, you’ll see that the file is highlighted in red indicating that the data has not yet been committed to our GitHub account.

git status

Example Output:


Step 3: Adding an Index to GitHub

Adding an index for your script can be done by using the git addcommand. Once you perform the command, you’ll see your script name is now highlighted in green, letting you know it's been appropriately indexed.

git add

Example Output:


Step 4: Committing the Script

Commit the script by utilizing the commit command followed by the -m flag. Place the command of your choice in quotes along with the file, Committing your script pushes the script to your local repo.

git commit -m "First java program"

Example Output:


Step 5: Pushing Script to GitHub Account

Committing the script means that the changes to your file have been recorded, but it doesn’t mean that they were pushed to your remote repository or your GitHub account. To push to GitHub from the terminal, use the push command. Afterward, you’ll be prompted to put in your username and password to your GitHub account.

git push -u origin master

Example Output:

root@merovingian2:~/git_environment/test# git push -u origin master
Counting objects: 3, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (3/3), done.
Writing objects: 100% (3/3), 465 bytes | 232.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
   cd5837c..a19b483  master -> master
Branch 'master' set up to track remote branch 'master' from 'origin'.

Step 6: Verifying the Push

We can verify that this script was pushed to our repo by going to our GitHub account and refreshing the screen for your particular repo.  In our pictured example, my is now present.



GitHub has many exceptional uses. Not only is it used for code storage and versioning, but it can also be utilized for storing blog info, images, lists of any kind, handbooks, ongoing documentation, datasets, or even recipes! All in all, GitHub is an excellent tool to have in your skillset. Adding how to commit changes to GitHub only enhances those skills.

We pride ourselves on being The Most Helpful Humans In Hosting™!

Our Support Team is full of experienced Linux technicians and talented System administrators who have intimate knowledge of multiple web hosting technologies, especially those discussed in this article.

If you are not currently hosted with Liquid Web, our Sales team is always available to answer any hosting inquiries 24 hours a day, 7 days a week, 365 days a year.

If you are a Fully Managed VPS server, Cloud Dedicated, VMWare Private Cloud, Private Parent server, Managed Cloud Servers, or a Dedicated server owner with Liquid Web and you are uncomfortable with performing any of the steps outlined, we can be reached via phone at 800.580.4985, a chat, or support ticket to see if we can assist you with this process.

Avatar for David Singer

About the Author: David Singer

I am a g33k, Linux blogger, developer, student, and former Tech Writer for My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....

Latest Articles

How to Make OpenStack Work for You

Read Article

How to Install MediaWiki on CentOS 7

Read Article

Five Steps to Create a Robots.txt File for Your Website

Read Article

Premium Business Email Pricing FAQ

Read Article

Microsoft Exchange Server Security Update

Read Article