How to Get Started with GitHub

This video explains how to get started with GitHub, including how to create a repository and work with commits, pull requests, and merges.

Christopher Tozzi, Technology analyst

March 25, 2023

12 Min Read
GitHub logo
Alamy

The following is a transcript of the video above, which walks through getting started with GitHub.

Chris Tozzi: Hey folks, this is Chris Tozzi with ITPro Today, and I'm here to talk about getting started with GitHub. The purpose of this video is to provide an introduction and show you how you can get started using it. Specifically, we'll talk about what GitHub is. And then we'll walk through how to get started setting up a repository, adding a file to the repository, and then working with pull requests.

These are the very basic, essential core tasks that you would want to complete if you're brand new to GitHub. If you're already familiar with GitHub, and you're looking for a dive into some of GitHub's more advanced features, then check out some of our other videos where we look at things like how to work with tokens for authentication in GitHub, or how to take advantage of GitHub's collaboration and security scanning features.

Download This Free Guide to What You Need to Know About GitHub

But for now, we're going to stick to the basics, and I'll try to keep this short and sweet. So let's get started by talking about what GitHub actually is.

What Is GitHub?

I think that the easiest way to explain what GitHub is, is to say that GitHub is basically a web interface for Gits. Now Git, as you may know, is an open source version control and source code management tool that was written by Linus Torvalds in the mid-2000s. Git runs on basically any operating system. I'm using it here on Ubuntu, but you can use it on Windows or MacOS or pretty much whatever you want.

Related: GitHub vs. GitLab: Which One Is Better for Your Enterprise?

If you type "Git" into your terminal, you will see that you get a list of commands that you can pass to Git to do different things like create a repository, which is where you would host source code or a project, or you can compare files within repositories and do all these cool things.

But a limitation of Git is that Git doesn't offer any interface beyond the command line. So if you don't want to spend all day working in the command line, then you need to use Git in conjunction with an external tool, like GitHub. Part of the value of GitHub, part of the reason GitHub is so popular, is that it offers a web-based interface that you can use for doing all the things that you could do with Git.

Now GitHub also does a lot of other things. GitHub has a lot of special features that are not part of Git itself. It has, for example, GitHub Actions, which is a way to drive collaboration with other developers. It has built-in security scanning. It has even now interesting, like AI, these cogeneration features. None of these things are built into Git itself.

So to say that GitHub is just a web interface for Git is kind of simplistic. It's a lot more than that. It's also, by the way, a hosting solution for source code. If you use GitHub, you don't actually have to set up your own repositories on your own server or on your local development box to host source code. You can just do it on GitHub servers, and it's fully managed for you.

So GitHub offers lots of value beyond just being an alternative interface for Git, but I think that in the most essential sense, the reason why GitHub is popular is that it's a way to use Git without having to use the command line. Although I should say to be clear, you can still use the command line to interact with GitHub, based upon the repositories that you want.

So that's part of the reason GitHub is cool, and it's totally compatible with command line based workflows, and you can push code from a local machine to a GitHub repository using the command line if you want, but you don't have to. If you want to work through a web interface, you have that option as well.

So GitHub basically gives you a lot more options that you wouldn't have if you use just Git.

Getting Started Using GitHub

So now let's look at how to get started using GitHub. And I'm not going to walk through how to create an account because it's super, super easy.

We'll show you how to do that in case you're wondering. You just go to github.com, and you click the Sign Up button. And it is so easy that GitHub actually walks you through the process. It's actually like an interactive setup, sort of wizard I guess you could call it. So again, I'm not going to show you how to do that. I have full confidence that you can create this app on your own.

Once you create an account and you sign into GitHub, you will see a screen like this. And the most important part of the GitHub homescreen for a user who's logged in is what you see on the left here. This is a list of repositories that I've either created or that I have worked on. And again, repositories are important because they're where you manage source code. And typically, you would create a separate repository for every project that you have. Now, technically speaking, you could use a single repository for multiple projects, but that wouldn't really make sense. It would create a lot of issues. That's not how Git is designed to work.

Creating a Repository in GitHub

So generally, whenever you start a new project, you would create a repository. So let's look at how to create a repository in GitHub. It's really easy. You just create this button, and GitHub brings up a screen where it basically walks you through how to create a repository, and there's really not much to it. The only thing you really have to do is give your repository a name. So let's give it a unique name. Actually, a "unique name" is available, which surprises me.

You can choose to make your repository public or private, depending on what your needs are. Typically, most repositories on GitHub are public, but you know, I guess it's impossible to know because nobody can see the private ones if they don't have access. But anyway, I'll make this repository public just for good measure.

And I should note, by the way, that if your repo is public, that doesn't mean that anyone can actually modify your code. You can still define access control policies that give people read-only rights to your repository, but you can also let random people make commits, if you want.

I can make GitHub basically a change to code inside your repository. And we'll talk more about that in a moment. But anyway, for now, we'll just stick with the default settings, make this public.

You can also add a readme file by default. You can add a Git Ignore file if you want. You can choose the license. But all this stuff is optional, so we'll just skip it for the purposes of being short and sweet.

So we're going to click Create Repository, and it's that simple. As you can see, we just made a new repository on GitHub.

However, at this point, our repository has no contents. If you actually went to this URL, you'd see that the repository is just empty. So what we want to do is create a file for this repository. And I won't actually add source code to it. Now, we're going to pretend there's source code. So the easiest way to create a new file is just to click this link, although you can also push code directly or push a file directly from your local machine to GitHub from the command line if you want. I told you that.

One of the cool things about GitHub is that it doesn't force you to use the command line, but you can totally use the command line if you feel like it. And actually they show you what the commands would be if you wanted to push code to this particular repository, as you'll see here.

This command in particular is tailored so that you could push code directly to this repository. But again, we're not going to do that. We'll just click the link and use the web interface to create a new file. And GitHub actually opens up a text editor where you could write code. Now again, I'm not going to actually write code, but we'll pretend ... we'll say here's some code.

We also have to give our file a name. And we'll just call it "code create" just to keep it simple. Now, to be clear, not every file that you would store in a GitHub repository has to be code per se. You can also store readme files. You can store documentation files.

You can also store binaries if you want, although GitHub is not designed to be a place where you would post and try to distribute binary application files for the most part. You would instead use Docker Hub for that or one of the Python repositories or a Ruby repository or whatever.

GitHub is designed mostly for hosting source code. But strictly speaking, it can host other types of things as well.

We'll create a new file. Now we could make a description for our commit in that this is basically a way to document the reason we're making this change. And we'll just say, "created our first file." And now we'll click "Commit new file." And as you can see, now in our repository, we actually have a file, and we can click on the file and we can see its contents and see that the contents of the file are something that says, "here's some code."

How to Create a Branch

Now, let's imagine that we want to modify the code in our repository, but we want to create our modification separate from the main code. So the way to do that is to create a branch. And the branch is basically part of a repository that contains a unique set of changes that are different from other branches that exist within the same repository.

So what we're going to do now is create a new branch, and we'll call it our dev branch. And that's going to be separate from me. Now if we click the dev branch, we will see that for now it contains the same file with the same contents as our main branch, but what we can do is actually modify this file.

Related: How to Delete a Local or Remote Branch on Git and GitHub

Let's say we want to change it. We'll modify it to, say, "Here's some updated code." And now we're going to make a commit. "We updated the code" will be our commit message, and we're going to commit the change. And what we can do now is go back to our repository and under the dev branch, this file, which is named "code," contains the text "we updated the code." But if we go back to our main branch, we will see that it contains the original version of our code, which says, "here's some code" instead of "here's some updated code."

Making a Pull Request

So what we have now is a single repository that contains basically two different versions of the same file. And let's say that we want to take the changes we made in our development branch and merge them back into our main branch. The way that we do that is to make a pull request.

So let's go ahead and do that. A pull request on GitHub is basically a way of saying, "Please take my changes and integrate them into another branch."

And generally, when you make a pull request, you're making it to other developers. You typically wouldn't make a pull request to yourself, although actually you could. There are actually situations where you would want to do that. But in general, pull requests are one of the core collaboration features in Git and GitHub. So anyway, let's make a pull request.

We can send a message saying why we want them to accept our pull request. We'll just say, "please accept pull requests," and we're going to click Create Pull Request, and GitHub by the way will automatically try to determine whether the branches can be merged. And in this case, they can be.

There are no conflicts because we're dealing with really simple files, but there could be conflicts if they weren't so simple.

So anyway, what we can do now that we created a pull request, the person who manages the repositories and branches can actually accept the pull request. So we're going to go ahead and do that, and we will say we will confirm the merge.

And now what will happen is that if we go back to our repository, we will see that right now we're in our main branch. And if we look at our code file, it will say it contains the updated version of our code. It contains the line that says, "Here's some updated code."

As you'll remember, we made this change in a different branch, and now we've merged it back into the main branch. So that's really cool. It's really cool, at least if you need to make a bunch of changes and you want to keep track of those changes, and make sure that changes in part of your code don't break other parts of your code.

And that's some of the cool stuff you can do with GitHub. Anyway, as I said, there's a ton more to say about GitHub, but we're going to end here because we've covered the very basics of getting started with GitHub by showing you how to create a repository, how to work with commits, pull requests, and merges. And that's kind of the most important, very basic, core set of features that GitHub offers. Although again, you can do a lot more, so check out our other videos if you're interested in deeper dives into some of GitHub's some more advanced features.

About the Author

Christopher Tozzi

Technology analyst, Fixate.IO

Christopher Tozzi is a technology analyst with subject matter expertise in cloud computing, application development, open source software, virtualization, containers and more. He also lectures at a major university in the Albany, New York, area. His book, “For Fun and Profit: A History of the Free and Open Source Software Revolution,” was published by MIT Press.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like