Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Development Tools Git Basics Working With Remote Repositories Cloning

Thomas Williams
Thomas Williams
9,090 Points

"cloned an empty repository" but repository contains files!

Thomass-MacBook-Pro:my_really_cool_project GroupPay$ ls

file1 file2 file3 my_really_cool_project

Thomass-MacBook-Pro:my_really_cool_project GroupPay$ cd ~

Thomass-MacBook-Pro:~ GroupPay$ ls

Applications Downloads Movies MyApplication2 clone_three our_clone_project Desktop Helloworld Music Pictures my_even_cooler_project our_other_clone Documents Library MyApplication Public my_really_cool_project

Thomass-MacBook-Pro:~ GroupPay$ git clone ~/my_really_cool_project/ clone_four Cloning into 'clone_four'...

warning: You appear to have cloned an empty repository.


Thomass-MacBook-Pro:~ GroupPay$ cd clone_four/

Thomass-MacBook-Pro:clone_four GroupPay$ ls

Thomass-MacBook-Pro:clone_four GroupPay$

Why do i keep getting an empty clone when the cloned repository shows to contain files??

1 Answer

Alexander Nikiforov
.a{fill-rule:evenodd;}techdegree seal-36
Alexander Nikiforov
Java Web Development Techdegree Graduate 22,158 Points

Repository may contain files, but if they aren't added to git repository is empty.

Imagine you have my_really_cool_project GroupPay directory

Then you type : ls

Thomass-MacBook-Pro:my_really_cool_project GroupPay$ ls

There are files, but they are not added to git

When you typed

git init

You initialize new git repository without file

If you type now clone

git clone ~/my_really_cool_project/ clone_four 

Then repository is still empty

In order to fill the repo you first have to add and commit

git add file1
git commit file1 -m "added file1"

This way you will add files to your repository

And then upon cloning there will be files...

Does it make more sense now ?

Thomas Williams
Thomas Williams
9,090 Points

Thanks Alexander, that did indeed solve my problem. I must have missed that step in the tutorial! But now that you have pointed it out, it makes sense. Many thanks.