If you are working on a project with multiple developers and you need to get code pushed every five minutes for testing, you definitely have to clone the project in your local computer to avoid any missing updates!
By following a few easy steps you will be able to clone any project from Gitlab (remember that you will need to have developer’s permissions in order to clone a project using SSH keys):
1.For starters you will absolutely need to create SSH keys in order to clone any project from your Gitlab account, specially if you have 2FA enabled.
2.To create SSH keys in Windows you will have to download Git Bash (you can follow the instructions here: http://www.techoism.com/how-to-install-git-bash-on-windows/)
3.Set up Git and email for identification (If you are planning to use Git for multiple projects)
4.Create an SSH key from Git Bash (Only for Windows) by entering the following line:
//START // ssh-keygen -t rsa -C “[email protected]” //END//
5.Select the folder where you want to store the SSH keys.
6.Once the folder is selected hit enter. You will have an option to enter a passphrase or password (if you want an extra layer of security I will recommend you to add a passphrase. This means that every time you will be cloning the project you will have to enter it – FYI the passphrase won’t be displayed so be careful when typing) Hit enter.
7.After completing this step, go to the folder where you store the SSH keys and open the id_rsa.pub file (Right click – any text editor like notepad and copy the key)
8. Go to your Gitlab Account and click on your avatar, then settings and on your left side you will find the SSH keys tab. Click there and paste the copied SSH in the empty box. Add Key.
9. Once your SSH key is added you will receive an email: SSH key was added to your account.
10. Now open CMD as an administrator and go to the folder where you want to clone the project. If you want to clone the project in C:\Users\your.user but your CMD opens in a different location just enter
cd C:\Users\your.user
This will locate the folder where you want to clone your project.
11. Then enter:
git clone [email protected]:username/projectname.git
12. To locate your git@gitlab url you will have to go to your Gitlab account, locate the project and on your right side you will have two options: SSH keys or HTTPS. As this tutorial is for those who have 2FA enabled you will have to copy the SSH keys url.
13. You will get a prompt: Are you sure you want to continue connecting? (yes/no) You will have to verify the authenticity of the host by entering yes.
14. After this the cloning process will start.
15. Now, go to your local folder and check if you have a folder with the name of the project.
16. Every time you need to push an update just open CMD, go to the local folder and enter git clone [email protected]:username/projectname.git (it will clone the latest updates)
I hope this works for you! If you have any questions you send me an email and I will get back to you shortly.
sophie(at)cybermaterial.com