git 浅提取不显示分支
git shallow fetch not showing branches
我之前用 --depth 1
做了一个 git 浅层克隆
之后,我想从远程获取一个深度为 10 的特定分支,然后结帐到该分支。
我可以从远程获取分支,但是分支没有显示在 git branch -a
更换个人信息后的日志如下
User@PC-NAME MINGW64 /d/Folder/application (master)
$ git fetch --depth 10 origin branchname
remote: Counting objects: 18624, done.
remote: Compressing objects: 100% (10327/10327), done.
remote: Total 18624 (delta 12993), reused 12045 (delta 7599)
Receiving objects: 100% (18624/18624), 530.73 MiB | 1.36 MiB/s, done.
Resolving deltas: 100% (12993/12993), completed with 3067 local objects.
From 10.100.x.x:Repository/application
* branch branchname -> FETCH_HEAD
User@PC-NAME MINGW64 /d/Folder/application (master)
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
浅层克隆中的默认 refspec 仅提及 refs/heads/master
(而不是 "regular" 克隆中的 refs/heads/*
),因此 git fetch
不知道本地引用应该是什么当你只提到 branchname
.
时会更新
对于一次性更新,请在命令行中提及显式引用规范:
git fetch --depth 10 origin branchname:refs/remotes/origin/branchname
对于定期更新,请在您的 .git/config
中添加 refspec :
# at the end of your [remote "origin"] section :
fetch = refs/heads/branchname:refs/remotes/origin/branchname
我之前用 --depth 1
做了一个 git 浅层克隆之后,我想从远程获取一个深度为 10 的特定分支,然后结帐到该分支。
我可以从远程获取分支,但是分支没有显示在 git branch -a
更换个人信息后的日志如下
User@PC-NAME MINGW64 /d/Folder/application (master)
$ git fetch --depth 10 origin branchname
remote: Counting objects: 18624, done.
remote: Compressing objects: 100% (10327/10327), done.
remote: Total 18624 (delta 12993), reused 12045 (delta 7599)
Receiving objects: 100% (18624/18624), 530.73 MiB | 1.36 MiB/s, done.
Resolving deltas: 100% (12993/12993), completed with 3067 local objects.
From 10.100.x.x:Repository/application
* branch branchname -> FETCH_HEAD
User@PC-NAME MINGW64 /d/Folder/application (master)
$ git branch -a
* master
remotes/origin/HEAD -> origin/master
remotes/origin/master
浅层克隆中的默认 refspec 仅提及 refs/heads/master
(而不是 "regular" 克隆中的 refs/heads/*
),因此 git fetch
不知道本地引用应该是什么当你只提到 branchname
.
对于一次性更新,请在命令行中提及显式引用规范:
git fetch --depth 10 origin branchname:refs/remotes/origin/branchname
对于定期更新,请在您的 .git/config
中添加 refspec :
# at the end of your [remote "origin"] section :
fetch = refs/heads/branchname:refs/remotes/origin/branchname