
In addition to being owned by Microsoft today, GitHub is the world's largest place for developers to sync, share, and collaborate on code. Big companies and solo superstars use GitHub, just like everyone else. If there is an open source project, it is probably hosted on GitHub.
But it's not only useful for people who write code. Anyone can pull code and files from a public GitHub repository, and there are unlimited projects you'll want to interact with at some point. From the biggest ones like Microsoft's Visual Studio Code orWindows package managerfor minors, such as using someone else's configuration files to design your terminal. If some kind of code is needed, it can be done via GitHub.
But while you don't need to know how to code to use GitHub, things can be a bit confusing for beginners. It doesn't have to be this way, so here are some of the basics you need to know.
Setting up a GitHub account
You don't need a GitHub account to browse code and clone repositories, but it's worth signing up for. With just your own account and repository space, you can save your own files and fork other projects, follow other members, and bookmark repositories for easy access later. It is completely free and does not require a Microsoft account.
With a GitHub account, you can also use the often overlooked GitHub CLI terminal app, which you should have due to some changes to the way GitHub allows accounts to authenticate. More on that later.
You do notTerto interact with GitHub via the terminal, but in many cases it's the most efficient workflow. Instead, there's a GitHub desktop app for Windows, Mac, and Linux if you prefer something with a GUI. But for the purposes of this guide, we are going to focus on the terminal. It's not scary, I swear!
Install Git and GitHub CLI on your PC
The main tool you'll use 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 is a version control tool that allows multiple people to independently interact with the same files, with the option of merging changes into the master branch.
For now, we'll just cover the most important commands you need to know to start cloning GitHub repositories to your PC, but look for a more detailed guide on Git soon.
To install Git on Windows, just go toGit for Windows websiteand download the executable, or if you want to use the Windows Package Manager, open a new PowerShell window and type it
Winget instala git
.
On WSL distributions like Ubuntu and Debian, you can install Git with the command
sudo apt install git
. Simply.
The GitHub CLI Tool is an official GitHub application and can wait for now if you don't plan on uploading anything to a GitHub repository yourself. If so, it's worth it as it avoids using Git's personal access tokens.
To install the GitHub CLI on Windows, you can use the Windows package manager again by typing
winget install github.cli
, or get it directly from GitHub. Alternatively, it's also available in the Scoop and Chocolately package managers, where you just need to install it.
gh
.
On Linux and WSL, there are different methods depending on which distribution you use, butGitHub has full documentationyou can follow Mac users can also download the GitHub CLI application, either frompublished pageor via Homebrew, Conda, MacPorts and Spack where to find it
gh
.
Clone your first repository from GitHub
Cloning a GitHub repository is basically like syncing a folder to your PC from the cloud. The repository creates a new local folder and contains everything that was available in that repository. Typically, a GitHub repository is dedicated to a single project, so cloning will give you everything you need. If more dependencies are needed, there will almost always be one.
LÉAME.md
File with complete instructions.
Cloning the repository in terminal will create your local folder in the directory your command line is in at that point. So if you want to put it in a specific location, find the correct location in File Explorerthe right button of the mouseand open it in PowerShell/Windows Terminal. WSL distributions can also access the Windows file system. So if you're using Linux on your Windows box, the same idea applies. It is only stored in the Linux file system when you request it.
So, it's time to clone. For this example, we are going to clone the Microsoft Visual Studio Code repository.
- Locate the desired repository on the GitHub website. For this example we usehttps://github.com/microsoft/vscode
- Click the button labeledCode.
- ChooseHTTPS.
- Copy URL.
- Open the chosen terminal. Whether it's WSL, PowerShell, Mac, or Linux, the Git commands are the same.
- between non-terminal
git-Clone https://github.com/microsoft/vscode
There are other cloning options, including SSH and using the GitHub CLI client, but this is the easiest method, especially for beginners. It's also the method you'll find in most tutorials and many installation instructions you can find on GitHub.
You have now downloaded everything from the Visual Studio Code repository to your PC. You can't make changes and push them back to GitHub (known as pushing) because you don't have the necessary permissions, but if you want to use or modify the code on your local machine, you can. To see the contents of the directory, you can type it
cd-vscode
in the terminal and do a
ls
or on windows you can type
explorer.exe.
to open File Explorer in that directory.
You now know the basics of using Git to clone GitHub repositories. The only ones you can't clone are private repositories you don't own, but anything else that's public is fair game. When you no longer need the files, simply delete them from your local computer. They do not affect the remote repository. If you want to get the latest files from this repository at any time, make sure you are in terminal in this directory and just type
pull git
to download the latest changes.
GitHub CLI authentication with your account credentials
If you want to go a step further with GitHub and start uploading your own files, I recommend having the GitHub CLI app in your arsenal as well. It is a command line tool that coexists with Git and is specific to GitHub (Git itself can also interact with various services like GitLab and BitBucket).
GitHub no longer allows you to authenticate to Git with your account username and password, which requires a personal access token. The easiest way to authenticate your system is with the GitHub CLI, themay lUse your account username and password. To use it, open your terminal and follow these steps. Again, all the steps are the same whether you're using Windows, Mac, WSL, or Linux.
- between non-terminal
gh authentication login
- ChooseGitHub.com.
- ChooseHTTPSlike a record
- untilYto authenticate with your GitHub credentials
- BeatGet intoto log in with a web browser.
- Type the one-time use code that is presented to you and pressGet into.
- A browser will open, and you'll need to sign in to GitHub if you haven't already.
- Enter the unique code in the field.
You are now connected to the GitHub CLI client, and there are several things you can do with it, in addition to being able to push code with Git. To see the full list of commands, just type
g- help
not end device.
Setting up your first GitHub repository
There are two ways to easily set up your first GitHub repository. You can use the website or, now that you're connected to the GitHub CLI, create one with a few commands in a terminal.
This is what you need to do for both methods.
Launch the GitHub home page and make sure you're signed in to your account. Follow the steps below to create a new repository.
- to tight+in the upper right corner.
- Choosenew deposit.
- Give your repository a name. This is required, whether public or private.
- Choosein publicoPrivatedepending on what you need.
- If necessary, select one of the optional files or licenses.
- cliquecreate deposit.
One of the files that it can generate automatically is a
LÉAME.md
Text file. You don't need any of these, but it's a good idea to have one, as it's the file that contains all your future information. Anything you write to this file will appear in your repository. If it's private and you're not going to share the content, it doesn't matter much.
You've now created your first GitHub repository! To sync it with your local PC, please follow the steps above to clone it.
Using the GitHub CLI
Since most of your time using GitHub is spent in a terminal, the command line is a quick and easy place to start a new GitHub repository using the GitHub CLI. The added benefit here is that the repository is already linked to a local folder, configured, and ready for Git.
- Navigate to the local directory that you want to sync with a GitHub repository using
CD
in terminal or by opening terminal in File Explorer. - Get into
start git
and press Enter. - Once the empty git repository is created, type
Create gh repository
. - Give the repository a name (pressget intoto use the folder name).
- Give the repository an optional description and press Enter.
- Select the visibility for the repository withcursor keysand press Enter.
- untilYand press Enter to continue and create an Origin Git Remote.
- When it's done, you'll see a success message and confirmation of the remote you just created.
The most important steps here are the first two because without them you can't create a repository using the GitHub CLI. All Git repositories should be initialized, and if you clone one from GitHub, it already contains the necessary files. The end result is the same, but with this method you can quickly create a GitHub repository and link it to your local/git repository folder, ready to commit and push.
Push to GitHub from the command line
You now have your own GitHub repository. It's time to move some files there. Regardless of the method you used to create it, there are still a few steps you need to take after linking it to your local computer. The following steps assume that you have followed everything up to this point and have used the GitHub CLI to authenticate your system with your account.
First, you need to tell Git who you are. You can't push anything to GitHub without doing so first. Open a terminal and type these two commands.
git config --global user.name "your username" git config --global user.email "your email address"
Every time you push something from your PC to GitHub, that information is attached. In smaller cases, like personal repositories, this isn't as important, but the system is designed to accommodate large organizations as well.
Now we can push the content of our local Git repository to GitHub.
- Get into
add git.
on the end device. Since this is an initial push, we assume you want to send all the files. For individual files, replace period with the name of the file. - Confirm that the files are being deployed
git status
.
- Now you have to confirm the files provided with
git commit -m "insert message here"
. The message is required, but for the first time"First use"it's good.
- To press, type
git push --set-upstream Fuente maestra
and press Enter.
The length of the insert depends on the size of the directory, but once it's done you'll receive a confirmation and be sent back to a blank message. you can use
git status
always check if the mounted files need to be committed. Also note that step 4 is only required for the first commit. For future boosts, you can just use
git push
to push all committed files to the GitHub repository.
That may seem like a lot to do, but once you're set up to use GitHub and have spent some time using it both on the web and on your local machine, it quickly becomes second nature. Everything discussed here will get you fully set up and cover the basics needed to clone, push, and pull to and from GitHub.
Windows Central Newsletter
Get the best of Windows Central delivered to your inbox every day!
ricardo devine
Editor-in-Chief: Technology, Reviews
Richard Devine is the editor-in-chief of Windows Central with over a decade of experience. A former project manager and longtime tech junkie, he joined Mobile Nations in 2011 and has been found on Android Central and iMore, as well as Windows Central. He is currently responsible for the site's coverage of all types of hardware and PC reviews. Find it on Mastodon belowmstdn.social/@richdevine