Repository initialization

Newer versions of git can clone an empty repository, but older versions only clone repositories that have been initialized with some data.

In this tutorial you are going to see whether the repository can be cloned, and if not, then to put some data into it, then try to clone it again to see how it now goes.

Open a terminal, and issue the commands as given.

cd

In the tutorial about setting up the repository, the systems administrator had given the URL of the repository that was created. In the current tutorial we assume a URL of "file:///media/usbstick/repository". Of course others are possible, depending on what type of repository you have and where it resides.

Now try to clone the repository:

git clone file:///media/usbstick/repository

If it says that an empty Git repository was created, and there is no fatal errors, then everything is fine. There is no need to proceed with anything that follows in this document.

However, if it gives a fatal error, then some work is to be done for proper initialization of the repository. Please read on.

You need to put something into the repository. It does not matter what, anything will do. Let's proceed and put an empty file into the repository. Issue the commands as given:

cd
mkdir repository
cd repository
git init

It will say that an empty Git repository was initialized.

touch file
git add file
git commit -a -m init

It will say that an initial commit was created.

git push --all file:///media/usbstick/repository

It will give some information, which shows that data was written to the repository. No errors should occur.

Clean out the temporal directory:

cd
rm -rf repository

Now try to clone the repository again:

git clone file:///media/usbstick/repository

It should say that an empty Git repository was created, give some more information, and show that object were received. It is does this, and there are no errors, then everything is fine. Your repository has been initialized.