How to set up a new GitHub project

Zamzam Abdulkadir
6 min readMar 23, 2021

What is Github?

To understand GitHub, you must first have an understanding of Git. Git is an open-source version control system; meaning, it enables developers to collaborate, as they can download a new version of the software, make changes and download the latest version of the software.

Github in other words is a code hosting platform for version control and collaboration. It lets you and others work together on projects from anywhere. Let's take a dive into understanding Github.

Setting up Git and Github

First, you’ll need to sign up for an account on GitHub.com. It’s as simple as signing up for any other social network. Keep the email you picked handy; we’ll be referencing it again soon.

You could stop there and GitHub would work fine. But if you want to work on your project on your local computer, you need to have Git installed. In fact, GitHub won’t work on your local computer if you don’t install Git. Install Git for Windows, Mac, or Linux depending on your preference.

Now it’s time to go over to the command line. On Windows, that means starting the Git Bash app you just installed, and on OS X, it’s a regular old Terminal. It’s time to introduce yourself to Git. Type in the following code:

git config --global user.name "Your Name Here"

Of course, you’ll need to replace “Your Name Here” with your own name in quotations. It can be your legal name, your online handle, anything. Git doesn’t care, it just needs to know to whom to credit commits and future projects.

Next, tell it your email and make sure it’s the same email you used when you signed up for a GitHub.com account just a moment ago. Do it like this:

git config --global user.email "your_email@youremail.com"

That’s all you need to do to get started using Git on your computer. However, since you did set up a GitHub.com account, it’s likely you don’t just want to manage your project locally, but also online. If you want you can also set up Git so it doesn’t ask you to log in to your GitHub.com account every time you want to talk to it. For the purposes of this tutorial, it isn’t a big deal since we’ll only be talking to it once. The full tutorial to do this, however, is located on GitHub.

Repositories

A repository is a directory or storage space where your projects can live. Sometimes GitHub users shorten this to “repo.” It can be local to a folder on your computer, or it can be a storage space on GitHub or another online host. You can keep code files, text files, image files, you name it, inside a repository.

Creating online repository

Now that you’re all set up, it’s time to create a place for your project to live. Both Git and GitHub refer to this as a repository, or “repo” for short, a digital directory or storage space where you can access your project, its files, and all the versions of its files that Git saves.

Go back to GitHub.com and click the tiny book icon next to your username. Or, go to the new repository page if all the icons look the same.

Creating local repository

So we just made a space for your project to live online, but that’s not where you’ll be working on it. The bulk of your work is going to be done on your computer. So we need to actually mirror that repository we just made as a local directory.

This — where we do some heavy command line typing — is the part of every Git tutorial that really trips me up, so I’m going to go tediously, intelligence-insultingly slow.

First type:

mkdir ~/blog-repo

mkdir is short for make directory. It’s not actually a Git command, but a general navigational command from the time before visual computer interfaces. The ~/ ensures that we’re building the repository at the top level of your computer’s file structure, instead of stuck inside some other directory that would be hard to find later. Actually, if you type ~/ into your browser window, it’ll bring up your local computer’s top level directory.

Also, notice that I called it blog-repo, the very same name I called my GitHub repository that we made earlier. Keep your name consistent, too.

Next, type:

cd ~/blog-repo

cd stands for change directory, and it’s also a navigational command. We just made a directory, and now we want to switch over to that directory and go inside it. Once we type this command, we are transported inside blog-repo.

Now we’re finally using a Git command. For your next line, type:

git init

You know you’re using a Git command because it always begins with git. init stands for “initialize.” Remember how the previous two commands we typed were general command-line terms? When we type this code in, it tells the computer to recognize this directory as a local Git repository. If you open up the folder, it won’t look any different, because this new Git directory is a hidden file inside the dedicated repository.

On your next line, type:

touch Readme.txt

This, again, is not a Git command. It’s another standard navigational command prompt. touch really means “create.” Whatever you write after that is the name of the thing created. If you go to your folder using Finder or the Start menu, you’ll see an empty Readme.txt file is now inside. You could have also made something like “Readme.doc”.

What’s going on? First of all, you’re on the master branch of your project, which makes sense since we haven’t “branched off” of it. There’s no reason to, since we’re working alone. Secondly, Readme.txt is listed as an “untracked” file, which means Git is ignoring it for now. To make Git notice that the file is there, type:

git add Readme.txt

Notice how the command line gave you a hint there? All right, we’ve added our first file, so it’s time to take a “snapshot” of the project so far, or “commit” it:

git commit -m “Add Readme.txt”

The -m flag, as noted in the terms directory in Part 1, simply indicates that the following text should be read as a message. Notice the commit message is written in present tense. You should always write your commands in present tense because version control is all about flexibility through time. You’re not writing about what a commit did, because you may always revert to earlier. You’re writing about what a commit does.

Now that we’ve done a little work locally, it’s time to “push” our first commit up to GitHub.

“Wait, we never connected my online repository to my local repository,” you might be thinking. And you’re right. In fact, your local repository and your online one are only connecting for short bursts, when you’re confirming project additions and changes. Let’s move on to making your first real connection now.

Connect Your Local Repository To Your GitHub Repository

First, we need to tell Git that a remote repository actually exists somewhere online. We do this by adding it to Git’s knowledge. Just like Git didn’t acknowledge our files until we used the git add command, it won’t acknowledge our remote repo yet, either.

Assume that we have a GitHub repo called “blog-repo” located at https://github.com/username/blog-repo.git. Of course, username should be replaced with whatever your GitHub username actually is, and blog-repo should be replaced with the actual title you named your first GitHub repository.

git remote add origin https://github.com/username/blog-repo.git

The first part is familiar; we’ve used git add already with files. We’ve tacked the word origin onto it to indicate a new place from which files will originate. remote is a descriptor of origin, to indicate the origin is not on the computer, but somewhere online.

Git now knows there’s a remote repository and it’s where you want your local repository changes to go. To confirm, type this to check:

git remote -v

Now we want to upload, or “push,” our changes up to the GitHub remote repo. That’s easy. Just type:

git push

Remember Rome was not but on a single day so don't fuss if you don't get it the first time.

--

--

Zamzam Abdulkadir
0 Followers

am a realist...it doesn't have to make sense to you 💯