In this video, we're going to copy a GitHub
repository to your local computer. The process I'll show you will work for a repo you created
yourself or a repo you forked from someone else. For this demo, I'm going to use the
"test-repo" that we created in the last video. Let's open up Git Bash. This shows my working
directory. I'm going to change my working directory to the Desktop. Now we're ready to go. Note that all git commands
start with the word "git", and then the name of the command, and then usually one or more
arguments. In this case, we're going to use the "git clone" command to clone a GitHub
repo. You simply type "git clone" and then the URL
of the repo. How do you get that URL? I recommend that you go to the repo, scroll down here,
and click the "Copy" button. Now go back to Git Bash, and at least in Windows, you can
hit the "Insert" button on your keyboard to paste it. (The usual paste keyboard shortcut
doesn't seem to work in Git Bash.) If all else fails, just paste the URL somewhere else
and retype it. If you're following along at home, you should
hit "Enter" at this point. I'm actually going to change my URL because I use SSH instead
of HTTPS to communicate with GitHub. I now hit Enter, and it asks me for my password.
When typing, it won't show you anything. Hit Enter when you're done, and if you typed the
wrong password, just try again. The cloning operation is now complete. It
has copied the repo into a subdirectory of my working directory, and that subdirectory
has the same name as the repo. So, I can just "cd" into "test-repo" and "ls" to see the
list of files. Notice that it now says "master". That indicates
that I'm now in a folder that is being tracked by Git, and I'm currently working on the "master"
branch. I don't need to run the "git init" command, because git has already been initialized
in the folder. On Windows, if you're set up to show hidden files, you can also see this
".git" folder where all of the Git information is stored. Next, let's check on your "remotes". Remotes
are simply references to repos that are not on your computer. To see your remotes, type
"git remote -v". You'll see a remote called "origin", which links to your repo. This reference
was automatically created during the cloning process. If you don't have an origin remote, you can
add one by typing "git remote add origin" and then the URL of your repo. The same one from here. We've now cloned the repo and set up a remote.
In the next video, we'll actually make some changes locally, commit them, and then push
them up to GitHub.