`git clone --depth=1` 之后怎样获取完整仓库?
巴扎黑
巴扎黑 2017-04-24 09:13:04
0
5
1089

只拿到了一个分支一个 commit, 再运行 fetch 也拿不到其他的分支和 commits 了.
尝试了 git fetch --all git fetch origin 无效.
用什么命令来获取完整的仓库呢?


更新:

搜到一段文章说不能继续... 不知道是不是真的:
http://strk.keybit.net/blog/2011/06/07/getting-just-the-tip-of-a-remote-git-branch/

A shallow repository (one with short history) cannot be further cloned,

巴扎黑
巴扎黑

reply all(5)
左手右手慢动作

Refer to the answers of @Leedy and @Evian and find that there is a unshallow parameter:

git fetch --help


--unshallow
           Convert a shallow repository to a complete one, removing all the limitations imposed by shallow repositories.
洪涛

(Did you solve the problem in the comments?)

$ git version
git version 1.8.5.3

$ git help clone
...
       --depth <depth>
           Create a shallow clone with a history truncated to the specified
           number of revisions. A shallow repository has a number of
           limitations (you cannot clone or fetch from it, nor push from nor
           into it), but is adequate if you are only interested in the recent
           history of a large project with a long history, and would want to
           send in fixes as patches.
...

It can be seen that git shallow clone can only clone the directory structure of the current remote/HEAD, excluding the history, so it is not a complete repo.

However, Git 1.9/2.0 has removed this limitation, see https://github.com/git/git/commit/82fba2b9d39163a0c9b7a3a2f35964cbc039e1a.

Reference: http://stackoverflow.com/questions/6941889/is-git-clone-depth-1-shallow-clone-more-useful-than-it-makes-out

PHPzhong
$ git fetch --help

--depth=<depth>

Deepen or shorten the history of a shallow repository created by git clone with --depth= option (see git-clone(1)) to the specified number of commits from the tip of each remote branch history. Tags for the deepened commits are not fetched.

大家讲道理

git fetch --depth=1000000

I saw a solution on stackoverflow, but it still didn’t work after I tried it.
http://stackoverflow.com/questions/6802145/convert-shallow-clone-to-full-clone

Peter_Zhu

git pull --unshallow

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template