How to - git clone
You have a repository online, probably from your current course. You've been told "Clone it for yourself " and you're wondering how? Yes then...
What do you need?
First of all, you need an account on the CoCo GitLab and a working SSH key for your PC or laptop. SSH what?
As a Windows user, it is easiest to use the GitBash. As a Mac user, simply use the terminal.
What does git clone actually do?
Git Clone downloads the repository to your PC / laptop. Then you have it locally on your device and can edit the files that are already in the repository, add new ones or delete them.
Ok and how do I do that now?
-
go to the GitLab page of the repository you want to clone. It will look something like this:
-
on the right you can already see the blue button with the inscription "Clone ". Click on it.
-
A submenu will now open:
Since you have an SSH key, the option "Clone with SSH " is the right one. Now you have to copy the link. The easiest way to do this is to click the button to the right of the link.
-
now open your terminal (Mac) or the GitBash (Windows).
-
navigate to the folder where you want to have the repository. e.g:
cd Git_Stuff
Git_Stuff
is the folder name. If your folder has a different name, you must enter the name of your folder aftercd
. -
are you in the folder of your choice? Then execute the following command:
git clone <what you copied in step 3>
-
Optional If you have set up a password for your SSH key, you will be asked for the password. You must then enter it. While you are entering it, you may not be able to see what you are entering. It will not be visible in the terminal or the GitBash! So you have to type it blind and then confirm your input with Enter.
8 Wuhuuu! Done! :)
All in all, it should have looked something like this in the GitBash or in the terminal:
-
cd Git_Stuff
This is how I navigated to the folderGit_Stuff
. -
git clone git@git.coco.study...
Now that I am in my target folder, I entered thegit clone
command with the address of the repository. I don't have a password for my SSH key, so I wasn't asked for it. Below you can now see what was downloaded. The last line from the blockResolving deltas: 100% (29/29), done.
shows me that it is finished, and since 29 of 29 objects have been transferred, it is also complete. -
ls
All folders and files that I have in theGit_Stuff
folder are listed. Theguides
folder is new. This is the repository that I have just cloned.