lab 17 Cloning Repositories

Goals

Go to the work directory 01

Go to the directory on top of you project folder.

Execute:

cd ..
pwd
ls

NOTE: Now in the work directory.

Output:

$ cd ..
$ pwd
/Users/jim/working/git/git_immersion/auto
$ ls
hello

At this point you should be in your “work” directory. There should be a single repository here named “hello”.

Create a bare clone of the hello repository 02

Let’s make a clone of the repository. The first repository we create here is intended to be a shared repository from/to which we will push/pull some data. Hence, it does not require a proper working directory, in other words it only needs to be a bare repository.

Execute:

git clone --bare hello shared_hello.git
ls

Output:

$ git clone --bare hello shared_hello.git
Cloning into hello.git...
done.
$ ls
hello
shared_hello.git

There should now be two repositories in your work directory: the original “hello” repository and the newly cloned “shared_hello.git” repository.

NOTE: The convention is that repositories ending in ‘.git’ are bare repositories. We can see that there is no working directory in the hello.git repo. Essentially it is nothing but the .git directory of a non-bare repo.

Create a (not bare) clone of the shared repository 03

In next labs we will see how to exchange data between multiple repositories. Let’s make a third copy of our project as a (not bare) clone of the shared repository.

Execute:

git clone shared_hello.git cloned_hello
ls

Output:

$ git clone shared_hello.git cloned_hello
Cloning into cloned_hello...
done.
$ ls
hello
shared_hello.git
cloned_hello

There should now be three repositories in your work directory.

Have a look at the cloned repositories 04

Let's have a look at the difference bettween the two new repositories.

Execute:

ls -F shared_hello.git

Output:

$ ls -F shared_hello.git
branches/  config  description  HEAD  hooks/  info/  objects/  packed-refs  refs/

Execute:

ls -F cloned_hello

Output:

$ ls -F cloned_hello
hello.c  Makefile  README

Table of Contents