How to get started using GitHub
You don’t have to be a master programmer to use GitHub.
When you purchase through links on our site, we may earn an affiliate commission.Here’s how it works.
Besides being a Microsoft property these days, GitHub is the largest place on earth for programmers to sync, share, and collaborate on code. Big companies and solo superstars use GitHub as well as everyone in between. If there’s an open-source project, chances are pretty high it’s hosted on GitHub.
But it’s not just useful for folks writing code. Anyone can pull code and files from a public GitHub repo, and there are limitless projects you might want to interact with at some point. From bigger ones like Microsoft’s Visual Studio Code orWindows Package Managerto smaller ones like using someone else’s configuration files to theme your terminal. If it needs some form of code, it can be done through GitHub.
But while you don’t need to know how to write code to use GitHub, to absolute beginners things can be a little confusing. It doesn’t have to be, though, so here are some of the basics you need to know.
Set up a GitHub account
You don’t need a GitHub account to browse code and clone repos, but it’s still worth signing up. Only with your own account and repo space can you store your own files and fork other projects, follow other members, and star repos for easy access later on. It’s completely free to use and doesn’t require you to have a Microsoft Account.
A GitHub account also allows you to make use of the oft-overlooked GitHub CLI terminal application, which due to some changes in how GitHub allows accounts to be authenticated, is actually something you should have. More on that later.
You don’thaveto interact with GitHub through the terminal, but in many cases, it’s the most efficient workflow. There is a GitHub desktop application for Windows, Mac, and Linux instead if you’d rather have something with a GUI. But for the purposes of this guide, we’ll be focusing on the terminal. It’s not scary, promise!
Installing Git and GitHub CLI onto your PC
The main tool you’ll be using with GitHub is Git. This can be confusing, but Git is the tool and GitHub is the service that interacts with it, Git is completely separate and has nothing to do with Microsoft. The basic definition of Git is that it’s a version control tool, allowing multiple people to interact with the same files independently with the option to merge changes into the master branch.
Get the Windows Central Newsletter
All the latest news, reviews, and guides for Windows and Xbox diehards.
For now, we’ll only be touching on the main commands you need to know to get started cloning GitHub repos to your PC, but look out for a more detailed guide on Git soon.
To install Git on Windows you can simply go to theGit for Windows websiteand download the executable, or if you want to use the Windows Package Manager, open up a new PowerShell window and enter
.
In WSL distros like Ubuntu and Debian you can install Git using the command
. Easy.
The GitHub CLI tool is an official GitHub application and for now, you can hold off if you’re not planning to upload anything yourself to a GitHub repo. If you are, it’s well worth having, as it gets around using personal access tokens with Git.
To install the GitHub CLI on Windows you can use the Windows Package Manager again by entering
, or grab it directly from GitHub. Alternatively, it’s available through the Scoop and Chocolately package managers, too, where you’ll simply need to install
.
On Linux and WSL, there are various different methods depending on the distribution you’re running, butGitHub has full documentationyou can follow. Mac users can also get the GitHub CLI application, either from thereleases pageor through Homebrew, Conda, MacPorts and Spack where it can be found as
.
Cloning your first GitHub repo
Cloning a GitHub repo is basically like syncing a folder to your PC from the cloud. The repo will create a new local folder and contained within it will be everything that was available on that repo. Generally, a GitHub repo is only dedicated to one project, so when you clone it you’ll get everything you need. If any further dependencies are required, there will nearly always be a
file with full instructions.
When you clone the repo in the terminal, it will create your local folder inside whatever directory your command line is in at that point. So if you want to put it somewhere specific, find the right location in File Explorer thenright-clickand open in PowerShell/Windows Terminal. WSL distros can also access the Windows filesystem so if you’re using Linux on your Windows box, the same idea applies. It will only save to the Linux file system if you tell it to.
So, time to get cloning. For this example, we’re going to clone the Microsoft Visual Studio Code repo.
There are other options to clone, including SSH and using the GitHub CLI client, but this is the simplest method, especially for beginners. It’s also the method you’ll find in most tutorials and in a lot of the installation instructions you might find on GitHub.
You now have the entire contents of the Visual Studio Code repo downloaded to your PC. You can’t make changes and re-upload them to GitHub (known as a Push) because you don’t have the permissions needed, but if you wanted to use or tinker with the code on your local machine, you can. To see the contents of the directory you can enter
in the terminal and do an
or on Windows, you can enter
to open File Explorer into that directory.
You now know the very basics of using Git to clone any GitHub repo. The only ones you can’t clone are private repos not under your ownership, but everything else that’s public is fair game. If you don’t want the files anymore, simply delete them from your local machine. They won’t affect the remote repo. If you want to get the latest files from this repo at any time, ensure you’re in that directory in the terminal and simply enter
to download the latest changes.
Authenticating GitHub CLI with your account credentials
If you want to go a bit further with GitHub and start pushing your own files to it then I highly recommend also having the GitHub CLI application in your arsenal. It’s a command-line tool that exists alongside Git and is specific to GitHub (Git itself can interact with multiple services such as GitLab and BitBucket also).
GitHub no longer allows you to authenticate with Git using your account login and password, instead requiring a personal access token instead. The easier way to authenticate your system is with GitHub CLI, whichcanuse your account login and password. To use it, open up your terminal and follow these steps. Again, all the steps are the same whether you use Windows, Mac, WSL, or Linux.
You’ll now be logged into the GitHub CLI client, and there are a number of things you can do with it besides just now being able to push code with Git. To see the full list of commands simply type
into the terminal.
Setting up your first GitHub repository
There are two ways you can easily set up your first GitHub repository. You can either use the website or if you’re now logged into GitHub CLI you can create one with a few commands in a terminal.
Here’s what you need to do for both methods.
Using GitHub.com
Fire up the GitHub homepage and make sure you’re logged into your account. To create a new repo follow these steps.
One of the files you can auto-generate is a
text file. You don’t need one of these, but it’s a good idea to have one since it’s the file that will contain all the front-facing information. Anything you enter into this file is displayed in your repo. If it’s private and you’re not going to share the contents, it’s not quite as important.
You now have your first GitHub repo created! To sync it to your local PC follow the steps above to clone it.
Using GitHub CLI
Since a lot of the time using GitHub will be spent in a terminal, the command line is a quick and easy place to initialize a new GitHub repo using GitHub-CLI. The added bonus here is that the repo will be already linked to a local folder, set up, and ready for Git.
The key steps here are the first two as without them you can’t create a repo with GitHub CLI. All Git repositories need to be initialized, and if you clone one from GitHub it will already have the necessary files within. The end result is the same, but with this method, you can quickly create a GitHub repo and link it to your local folder/Git repository ready to commit and push.
Pushing to GitHub from the command line
Now you have your own GitHub repository it’s time to push some files to it. Whichever method you used to create it, once it’s linked to your local machine there are a few more steps to do. The following steps assume you’ve followed everything to this point and have used the GitHub CLI to authenticate your system with your account.
The first thing you need to do is to tell Git who you are. You can’t commit anything to GitHub without first doing this. Open up a terminal and enter these two commands.
Now, every time you commit something to GitHub from your PC, this information will be attached. In smaller cases like personal repos it’s not that important, but the system is built to cater right up to large organizations.
Now we’re ready to push the contents of our local Git repository to GitHub.
How long the push takes depends on how large the directory is, but once it’s done you’ll get a confirmation and be sent back to an empty prompt. You can use
at any time to check whether there are staged files to be committed. It’s also worth noting that step 4 is only necessary on the first commit. For future pushes, you can simply use
to push all committed files up to the GitHub repo.
This may seem like a lot to take in, but once you’re set up to use GitHub and have spent a little time using it both on the web and your local machine, it all becomes second nature pretty quickly. Everything discussed here will get you fully set up and covers the basics you need to clone, push, and pull to and from GitHub.
Richard Devine is a Managing Editor at Windows Central with over a decade of experience. A former Project Manager and long-term tech addict, he joined Mobile Nations in 2011 and has been found on Android Central and iMore as well as Windows Central. Currently, you’ll find him steering the site’s coverage of all manner of PC hardware and reviews. Find him on Mastodon atmstdn.social/@richdevine