git clone 是空的?为什么会发生这种情况
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9004192/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
the git clone is empty? why this happens
提问by sraddhaj
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?
我打开msm
目录发现它是空的。这已经发生过。任何人都对出了什么问题有解释?
回答by Mika Fischer
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 存储库似乎在其master
分支上没有任何内容,这是 git 默认检出的分支。然而,它确实有另一个分支:
% 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.
然后工作树中还有内容。
回答by Dylan Kapp
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.
git submodule update --init --recursive
如果子模块中有子模块,也需要使用。
回答by Konstantin Pribluda
It seems that repository was cloned. Now you have to checkout something. What happens if you issue:
似乎存储库已被克隆。现在你必须结账。如果您发出以下命令,会发生什么情况:
git branch
回答by Roy Wasse
Also, what happened on my system just now (windows 7). The automatic initialization (git init) did not take place during the
另外,刚才在我的系统上发生了什么(Windows 7)。自动初始化 (git init) 没有发生在
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.
因此,如果在 git clone 之后目录为空(并且主分支不为空),则只需尝试 git init 。然后重复克隆。