33

This always perplexes me. I was cloning this

git clone https://android.googlesource.com/kernel/msm.git

And It seemed to be cloning resolving and receiving objects etc for long . Then when it is done...

git clone https://android.googlesource.com/kernel/msm.git
Cloning into msm...
remote: Counting objects: 1636832, done
remote: Total 1636832 (delta 1367313), reused 1636832 (delta 1367313)
Receiving objects: 100% (1636832/1636832), 324.89 MiB | 331 KiB/s, done.
Resolving deltas: 100% (1367314/1367314), done.

I open the msm directory to find it empty. This has happened before. Any one has an explanation as to what went wrong?

7ochem
  • 2,183
  • 1
  • 34
  • 42
sraddhaj
  • 581
  • 1
  • 7
  • 17

5 Answers5

49

This particular git repository seems to not have any contents on its master branch, which is the branch git checks out by default. It does however have another branch:

% git branch -a
* master
  remotes/origin/HEAD -> origin/master
  remotes/origin/android-msm-2.6.35
  remotes/origin/master

So if you check out this branch:

% git checkout android-msm-2.6.35
Checking out files: 100% (33866/33866), done.
Branch android-msm-2.6.35 set up to track remote branch android-msm-2.6.35 from origin.
Switched to a new branch 'android-msm-2.6.35'

then there's also content in the working tree.

Mika Fischer
  • 4,058
  • 1
  • 26
  • 28
11

After your first clone, if you have directories that are submodules of the parent repo, you need to initialize them with:

git submodule update --init

Using git submodule update --init --recursive will also be needed if there are submodules inside submodules.

Benjamin Castor
  • 234
  • 3
  • 9
  • Are the submodules their own git repo? – birwin Sep 13 '19 at 15:56
  • 1
    @birwin, yes git allows you to commit a hash (ie reference) of an entirely different git repo. This can be useful for common libraries. Making the library code a repo and adding it as a submodule to your project makes it a good way to share and maintain across different projects. (At that point it would be like picking up a dependency version that you can directly source control). – Benjamin Castor Sep 21 '19 at 18:47
  • That is a great feature. Thanks for clarifying. – birwin Sep 26 '19 at 15:34
3

It seems that repository was cloned. Now you have to checkout something. What happens if you issue:

git branch
Konstantin Pribluda
  • 12,329
  • 1
  • 30
  • 35
1

One simple solution is to use the following command.

> git clone -b <branchname> <remote-repo-url>

Here -b is just an alias for --branch. And you can replace "" with the branch name.

Abid
  • 96
  • 2
0

Also, what happened on my system just now (windows 7). The automatic initialization (git init) did not take place during the

git clone URL

Operation. Also got the same succesful clone msg.

After I did a 'manual'

git init

The clone operation resulted in a dir with contents. After I repeated it.

So, just try a git init if a dir is empty after a git clone (and the master branch is not empty). Then repeat the clone.

Roy Wasse
  • 390
  • 1
  • 10