Cloning, Staging, and Committing
Learn how a repository can be cloned and the process of staging and committing the code.
We'll cover the following
Cloning the repository
To begin adding and editing code related to this repo, you’ll now have to clone the repo. Cloning copies the entire GitHub repo to your local development environment.
To clone the GitHub repo to your local environment:
-
Navigate to the NoBSautomation repository (or whatever name you called the repo earlier).
-
Click the green Clone or download button. You will then be presented with two options: an HTTPS URL to copy and clone with and a Use SSH link to show the SSH to copy and clone with.
-
Let’s use the Clone with HTTPS option. This is the URL you will use to manually clone the repo via the local Git client.
-
Open a command prompt or PowerShell terminal as an administrator. The project will be cloning the GitHub repo to the desktop of the logged-in user (Michael), which will create a local folder on the desktop. However, you can choose any path you’d like.
-
With the copied HTTPS URL, run the command
git clone <https url>
. Thegit clone
command reaches out to GitHub and makes a copy of the repo to your local computer.
Once git clone
runs, it needs to authenticate to the repo since it’s private. When the GitHub Login box comes up, type in the username or email of the owner’s GitHub account and the password. Then click the blue Login button. The GitHub login page will go away, and the PowerShell terminal will show that the repository was cloned successfully.
Practice it here
In the terminal provided below, try out the commands to clone a repository from GitHub on your own. You can clone a repository that you’ve created or clone any other repository you want. As an example, try cloning this repository:
https://github.com/githubteacher/github-slideshow.git
This is a simple public repository for getting familiar with GitHub. You don’t need to worry about the contents of the repository itself.
You will need to enter the following command:
git clone https://github.com/githubteacher/github-slideshow.git
Try entering the command in the terminal below:
Get hands-on with 1200+ tech skills courses.