GitHub is a web-based platform used for project version command and codebase hosting. GitHub uses Git, a widely-used version control system. GitLab and Bitbucket are similar tools.

Using GitHub is a prerequisite of most of the tutorials on this site, then it is helpful to learn to use it. In this tutorial, I'll show yous how to push a projection to GitHub.

Prerequisites

To follow this tutorial, a few things are required:

  1. Basic knowledge of Git
  2. Git installed on your system
  3. A GitHub account

With GitHub set to become, we can start the tutorial.

Setting upwards

To continue things simple, we'll utilize a unmarried HTML file. You can review the HTML file hither.

In that location are a few ways to become the HTML file we demand.

  • Copy the code in the gist (linked higher up) into an index.html file
  • Get to this link, then click Download this 1 folio spider web-profile.
  • Use Terminal to go to the project folder you want to use and run:
          wget https://raw.githubusercontent.com/CIRCLECI-GWP/profile/master/index.html                  

Nevertheless you lot choose get the HTML, yous volition accept ane file, alphabetize.html, at the root of your directory.

For the balance of the tutorial, nosotros will utilise Terminal to run commands. Unless instructed otherwise, run commands at the root level of your project directory.

Initializing Git

Because we created our file locally, we need to button it to GitHub to shop it in that location. The offset footstep is initializing Git.

Run:

          git init                  

The git init control turns your directory into a new Git Repository.

Calculation files

With Git initialized, we need to marking it so that it is included in the next commit. This process is also called staging.

Run:

          git add .                  

This command marks all files in the repository, except for whatsoever in the .gitignore file.

Committing files

Our file is now marked and ready for its first commit. A commit is a snapshot of the history of changes to the file.

Run:

          git commit -m "Add index.html"                  

The text following -yard is the commit message. It is a human friendly reminder about what changes are in the commit.

Pushing to GitHub

Pushing uploads all your local commits to the remote repository. This makes the changes in your file available to people you are working with. In that location are two parts to this procedure:

  1. Creating a repository
  2. Pushing the project

Creating a GitHub repository

In your browser, go to github.com and log in if you demand to. Click the plus sign icon at the meridian right of the page. Then select New Repository.

New repo

Enter a proper name, then click Create Repository. I take used the name new-repository for this tutorial. We will be using this name later on, then brand a annotation of it.

Create Repository

There y'all have it, a sparkling new repository. If this is your first 1, congratulations! Y'all accept reached a programming milestone.

Stay on the Create Repository page to complete the adjacent stride.

Pushing the project to GitHub

So far in our project folder we have just one file, and we have committed the changes we made to it. The next step is to push these changes to GitHub. Our project is in 'new-repository', which nosotros only created, so we tin button to an existing repository.

Push existing repo

Click the clipboard icon to copy the 3 commands shown in the "push an existing repository from the command line' section. Paste them in your Terminal and printing ENTER to execute them.

Note: Replace the username shown in the lawmaking with your GitHub username.

          git remote add origin https://github.com/NdagiStanley/new-repository.git git branch -G main git push -u origin master                  

After running these commands, reload the browser page. Our index.html file is now listed in the online repository.

You can make more than updates to the repository by running these commands in order:

          git add together . git commit -m "Commit bulletin" git push origin primary                  

Supersede the sample message with a descriptive 1 of your own. If y'all are working on a branch other than main, supplant that with the name of the branch you are using. Yous tin read more about git branching here.

Decision

In this tutorial, yous pushed an online git repository to GitHub. Getting comfortable with Git and GitHub will allow y'all move on to the next pace of setting up a CircleCi project based on your GitHub repository. GitHub and other Git-based version control systems are widely used. Agreement them tin exist a key addition to your developer'south skill-set toolkit.


Virtually Stanley: From a young age, Stanley tinkered with electronics and building things with tech. His work involves information, the spider web, and IoT. Stemming from his lifelong love of DIY, he'southward on a personal journey of invoking the architect within and educational activity others forth the mode. He cares most how technology affects order and seeks collaborations with others who are working to create positive impact.