DEV Community

whatsacomputertho
whatsacomputertho

Posted on

What's Git & GitHub, Tho?

You may have heard of Git and GitHub, and you may have even used them before to share code or to grab someone else’s code. Still, though, many of you may be confused surrounding the nature and use of Git and GitHub. Some of you may not even know that these two things are different from one another. Regardless, I hope to explore both Git and GitHub conceptually and practically, and hopefully leave each of you with a greater understanding of what they are, and why they are used so heavily within software development.

Git is a software that tracks the contents of source files within a folder system. In the language of Git, this “folder system” is called a repository, a term which many developers abbreviate to “repo”. Meanwhile, GitHub is an example of a service which supports Git repositories. Namely, GitHub is a platform which hosts remote Git repositories, and allows developers to collaborate and to contribute to these repositories. Basically, any software project you’ve ever viewed on GitHub is simply a graphical display of a remote repository’s files and folders, as well as some additional information surrounding the collaboration which has taken place on the project.

See the following video for a more in-depth look into Git and GitHub, as well as a video tutorial for how to get started with Git and GitHub. If you would rather read through the setup portion of this tutorial, I went ahead and transcribed its steps and included this transcription below the embedded video.

Step 1: Create a GitHub Account

First and foremost, you’ll need to sign up for a GitHub account. Doing so will allow you to create your own remote repositories hosted by GitHub.

Step 2: Create a GitHub Repository

The repository you create will be empty when you create it, but soon, we’ll populate it with a test project.

Step 3: Install Git

This will allow you to interface with your local Git repository via the command line.
Git Download

Step 4: Identify or Create a Software Project On Your Hard Drive

Identify the project for which you would like to create a Git repository. In my video's demonstration, I used an existing project from a past video.

Step 5: Navigate to Your Project Folder via the Command Line

We will be interfacing with Git via the command line at the root folder of your identified project.

Step 6: Initialize Your Git Repository

Once you’ve navigated to your project folder, run the command:

git init

This command initializes your local repository.

Step 7: Add a Reference to Your Remote Repository

We can then add a reference to our remote repository by running the command:

git remote add origin [URL]

Replace "[URL]" with your remote repository's URL. We will use this reference later when we send our local repository to the remote one.

Step 8: Add Your Project's Source Files to Your Local Repository

We can add our source files one-by-one by running:

git add [FILENAME]

Replace "[FILENAME]" with the name of the file you would like to add. More simply, we can add all the files in your project by running:

git add *

Step 9: Commit Your Added Files

This will essentially save the current state of your repository. Do so by running:

git commit -m "message"

Add your own custom message within quotations to signify the purpose of the commit.

Step 10: Add a Main Branch to Your Local Repository

To do this, we’ll run:

git branch -M main

Step 11: Push Your Local Repository to Your Remote Repository

Push your local repository to the remote repository by running:

git push -u origin main

After running this command, refresh your GitHub repository in your browser, and you’ll see that your project has now been sent to your remote repository.

Top comments (0)