Clone an Existing Repository

Clone an Existing Repository#

Git makes sharing code convenient and easy. If you want to download code shared via git, all you need to know is the right address of the remote git repository that you want to clone (i.e. copy).

Open a terminal, and go to a folder into which you want to clone the repository (you will remember from the previous section):

cd /my/favorite/folder/

Clone the code from a remote git repository into that folder, for instance:

git clone https://git.rz.tu-bs.de/my-name-space/my-repo.git

Here you go! A subfolder has been created, which you may access via:

cd my-repo

After cloning a repository, you might want to work on it. In some cases, you don’t have the rights to push your changes back to the repository you cloned. You will encounter this issue for instance in the iRMB computer exercises. In order to allow git to keep track of your changes, you will need to create a new, own repository. In this case, the simplest way to unconnect from the remote repository you donwloaded from is by deleting the local .git folder:

rm -rf .git

Now, you can link your local folder to an own new git repository, that you have full access to. This is described in the next section.

Note

You have successfully cloned code from a repository, but is it executable? Well, it depends. Maybe, the code requires an older python version than you have installed on your system. Need help? Check out the section on Container Virtualization.