shou2017.com
JP

Directory Empty After git clone

Mon Feb 26, 2018
Sat Aug 10, 2024
Git

A common issue for beginners: “I cloned the repository, but the directory is empty.” Here’s how to handle it.

First, stay calm and run the following command:

$ ll -a  or ls -a

You might see something like this:

drwxrwxr-x 3 user user 4096  Feb 16 20:58 ./
drwxrwxr-x 8 user user 4096  Feb 16 20:58 ../
drwxrwxr-x 7 user user 4096  Feb 16 20:58 .git/

Although it seems empty, the .git directory is present.

Create a development branch and check it out:

$ git branch development
$ git checkout development

Next, confirm the remote repository with git remote:

$ git remote -v
origin	http://github (fetch)
origin	http://github (push)

Since the remote exists, pull the branch:

$ git pull origin development
From http://github
 * branch            development -> FETCH_HEAD
Updating 049f741..a15545
Fast-forward
 .gitignore                                         |  15 ++

Done!

Bonus

To change the remote URL:

$ git remote set-url origin http://github
$ git remote -v
origin	http://github (fetch)
origin	http://github (push)