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 and push a script from your Ubuntu server to your GitHub account.

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 add command. 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 pushing 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, aka your Github account, to do that 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 skill set.

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.

Should you have any questions regarding this information, we are always available to answer any inquiries with issues related to this article, 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 and you are uncomfortable with performing any of the steps outlined, we can be reached via phone @800.580.4985, a chat or support ticket to assisting you with this process.

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

Have Some Questions?

Our Sales and Support teams are available 24 hours by phone or e-mail to assist.


Latest Articles

Liquid Web’s Incident Management Process

Read Article

How Does Containerization Work?

Read Article

Microsoft Exchange Server Security Update

Read Article

How to Monitor Your Server in WHM

Read Article

How to Monitor Your Server in WHM

Read Article