Create a Git Repository and Push it to Github

By | November 6, 2015

In this post, you will learn how to setup a local git repository in Linux and upload it to your Github account.

Github is like a social networking site for computer programmers. You can share your code with the world so that anyone can view it, copy it, and improve upon it.

Create your Github account

Open a Github account and create a Github repository, but do not add any files to it.

Follow the instructions below to upload code from your computer to Github.

Setup Git

You can configure Git with a few simple commands.

Install git:

Set your git username. This name will be including in your commits for identification purposes.

An email is also required, but you can make it private.

Use these commands to confirm your username and email:

Change into the directory where your code is and initialize the git repository. This command will create a hidden .git directory in your code directory.

Find out which files in the project directory are being tracked by git. The files colored in red are not being tracked.

Add a specific file to the git staging index. As per Github, all repositories should include a README.md and LICENSE file. For example:

If you simply want to add everything within a directory to the git repository:

Check the status again to see that a commit is possible.

Commit a file to the repository (this packages everything in the staging index and sends it to the repository).

Push Repository to Github

Now to push the repository to Github. First, configure a Github origin. When you do this, you will be asked for your Github username and password.

Finally, push your repository to Github

You can now check your repository at github.com and verify that your commit was successful.

Github Video Series

The following is a great video series that explains what git is and how to use it:

 

Fork a Repository

https://help.github.com/articles/fork-a-repo/

Syncing a Fork

https://help.github.com/articles/syncing-a-fork/

 

Leave a Reply

Your email address will not be published.

*