GitHub: Pushing and Updating a Project Repo

David Scheibel
5 min readJun 4, 2021

--

This article will be a brief overview of GitHub and its powerful application as a project management and development tool.

GitHub is a massively popular web and cloud-based platform that allows for the storage and development of projects, project version control and hosting of codebase. It allows developers to build, collaborate, edit and debug projects from anywhere and hosts a variety of tools and open source best practices to more easily facilitate project development. GitHub does this primarily through Version Control and Git.

Version Control:

Version control allows developers to manage and track changes to a project’s code. It allows for individual elements of code to be worked on in a localized environment that protects the source code and enables multiple developers to work simultaneously and safely across the code base. Version control accomplishes this through branching and merging.

Branching allows a developer to duplicate part or all of the source code (called the repository or repo for short). Changes can be made to the local branch without affecting the project as a whole. Once the developer has their code in working order, they can merge that code back into the main source code.

Git:

Git is a specific open-source version control system created by Linus Torvalds in 2005. Specifically, Git is a distributed version control system, which means that the entire codebase and history is available on every developer’s computer, which allows for easy branching and merging.

Now that we understand the basics of GitHub and Version Control let’s get started creating and pushing a repo.

Building Our Repo:

There are several ways to go about creating a new repo and performing the set up linking it to your terminal. We will be following a simple step-by-step process using both GitHub.com and our terminal. We’ll begin by creating our repository on GitHub.

Creating a GitHub repo

Go to your browser and navigate to GitHub.com. If you have not already, create a profile and sign in. On your profile page, github.com/”YourProfileNameHere”, you will see a + icon in the top right hand corner. Click this and select “New repository” from the dropdown.

This will navigate you to the github.com/new address where you will be able to create your new repository. There will two required fields, one displaying the Owner (you) and the other a text box allowing you to enter the desired repository name. For this tutorial we are using “insert-name-here”. Not very creative but the repo name is for you to decide!

After you have satisfied those two requirements, there are several other things GitHub allows you to do. You can enter a Description in the Description field, set the repository to Public or Private, and initialize your repository with some helpful prefabricated files such as README, .gitignore and a license for your code.

All of these inputs are optional and the only requirement to initialize the repository, once the Owner and Repository name are set, is to click “Create Repository”.

Congratulations! You have a brand new git repo. Make sure to stay on the Create Repository page which will be needed for the final steps of this repository creation tutorial.

Now it’s time to set up the directory in your terminal that will keep track of information related to this git repo and initialize it. Let’s transition to our terminal and follow a few simple commands. We’ll begin by creating the directory we need with:

mkdir New-Directory
cd New-Directory

Now it’s time to initialize for git.

Initializing

Now that we’re in our New-Directory file in our local environment we have to push it to GitHub where it will be hosted. We will do this in the terminal within the directory we’re initializing. In your terminal, run:

git init

This command converts your local directory into a Git repository.

Staging Files

Now that the directory has been initialized we have to designate any changes need to be included when we commit the files to our web or could based storage. This process is called staging and is accomplished by running:

git add .

This command denotes all the files in the repository except any designated in the .gitignore file.

Committing Files

Now that our files have been designated they are ready to be committed. This step take a snapshot of the file when it was staged and adds it to a history of all changes made to the file. To commit simply run:

git commit -m "Helpful message"

The text following -m is the commit message. Usually a friendly indicator of what information and changes are included in the commit.

We’re now ready to push our repo to GitHub!

Pushing to GitHub

We left off in our browsers on the Create Repository page of GitHub. Navigate back to that page and, because our repository was just made and titled “insert-name-here”, we can choose to push to an existing repository.

Click the clipboard icon pointed to by the green arrow which will copy the three lines in the highlighted box:

Note: the text after git@github.com:___ will be your_username
Note: the text after your_username/___ will be the name of the repo

git remote add origin git@github.com:Egregious/insert_name_here.git
git branch -M main
git push -u origin main

You can always make more updates to your repository by a sequence of commands we used in the initialization stage of the directory. Those commands are:

git add . 
git commit -m "Helpful Message"
git push

You can also use a different git push command directly targeting the branch you want to push to:

Note: typically you would push to the branch you are working on

git push origin main

Summary

This tutorial has covered the creation, staging and pushing of an online git repository directly to GitHub. Learning how to quickly navigate GitHub especially with more advanced features like branching and merging will provide you as the user with tremendous project based version control ability. GitHub and over similar Git-based version control systems are integral to developers and the vast majority of development positions. Understanding GitHub and version control in general will be invaluable as you progress your abilities as a developer.

--

--