How to Commit and Push Changes from Ubuntu 18.04 to GitHub

Posted on by Ronald Caldwell | Updated:
Reading Time: 3 minutes

GitHub has many exceptional uses, such as:

  • Code storage.
  • Versioning.
  • Storing blog information.
  • Images.
  • Lists.
  • Handbooks.
  • Ongoing documentation.
  • Datasets.
  • Recipes

This tutorial builds upon a previous walk-through on creating and syncing a GitHub repository for your Ubuntu VPS server. Specifically, it will show how to commit changes to GitHub. The following steps push a script from your Ubuntu server to your GitHub account from the terminal.


  • Ubuntu 18.04 server.
  • Root user access to the server.
  • Git installed.

How to Commit and Push Changes to GitHub

Step 1: Create a JavaScript File

SSH into the server, open a terminal session and use the cd command to switch into the directory containing your GitHub project.

Use the mkdir command to create a directory if it was not done previously. It will include the following simple JavaScript program created in the Vim text editor from the terminal.

public class HelloWorld {

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


Step 2:  Check the New Script's Status

Use the following command to see if the file is committed to your GitHub account.

git status

The output shows the file name highlighted in red, indicating the changes have not been pushed to GitHub from the terminal and the file is not tracked by Git.


Step 3: Add an Index to GitHub

To add an index to GitHub so that Git tracks the script, use the git add command.

git add

Once performed, the command output shows the script name highlighted in green. It is appropriately indexed.


Step 4: Commit Changes to Local Repository

The following command commits your script to your local repository. Use this syntax.

git commit -m "First java program"

Committing the script changes uses the commit command followed by the -m flag. A description of the commit goes in quotes, followed by the file name. The following output is displayed.


Step 5: Push Script to GitHub From Terminal

The git push command commits and records the changes to your remote repository or your GitHub account.

To push the script to GitHub from the terminal, use the following command.

git push -u origin master

You will receive a prompt for your GitHub account username and password. After logging in, the following output will display.

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'.

Verify the Push 

To verify the script commit on GitHub, log into the account. Refresh the screen for the particular repository if you are already logged in. It shows both the file name and the description provided in step 4.



This tutorial outlined steps regarding how to commit and push changes from your Ubuntu 18.04 server to your GitHub repository. Then, using the syntax shown with your personal file names and descriptions, you are on your way to committing your changes on GitHub.

GitHub is an excellent tool to have in your skillset. Adding how to commit changes to GitHub only enhances those skills.

Do you need a hosting solution for your next JavaScript project? Liquid Web’s virtual private servers are an excellent fit for developers to start projects and scale to a higher server as needed. Contact our sales team today to get started.

Avatar for Ronald Caldwell

About the Author: Ronald Caldwell

Ron is a Technical Writer at Liquid Web working with the Marketing team. He has 9+ years of experience in Technology. He obtained an Associate of Science in Computer Science from Prairie State College in 2015. He is happily married to his high school sweetheart and lives in Michigan with her and their children.

Latest Articles

How to install Puppet Server on Linux (AlmaLinux)

Read Article

Deploying web applications with NGINX HTTP Server

Read Article

Email security best practices for using SPF, DKIM, and DMARC

Read Article

Linux dos2unix command syntax — removing hidden Windows characters from files

Read Article

Change cPanel password from WebHost Manager (WHM)

Read Article