首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何不忽略"not found in upstream,using HEAD“?

如何不忽略"not found in upstream,using HEAD“?
EN

Stack Overflow用户
提问于 2013-03-14 02:01:20
回答 2查看 6.5K关注 0票数 2

我正在编写shell脚本,以便从远程存储库部署git分支。

这是我使用的命令:

代码语言:javascript
复制
   git clone -q --depth=1 https://my.repourl.com/git-repo.git /my/destination/folder -b develop

问题是,如果分支(在本例中是develop)是错误的,它就会忽略并从主分支(?)中提取。我得到了这样的信息:

代码语言:javascript
复制
  warning: Remote branch devel not found in upstream origin, using HEAD instead

如果git找不到指定的分支,我只想让它死掉/退出。有什么标志吗?或者其他选择?由于某些原因,git-archive不能工作。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2013-03-14 03:47:07

作为twalberg comments,是用于检查远程端上是否存在分支的命令。

问题"How to check if remote branch exists on a given remote repository?“列出了另一种可能性:

代码语言:javascript
复制
git clone -n
git fetch
# parse git branch -r

测试(bash)可能如下所示:

代码语言:javascript
复制
br=$(git ls-remote --heads https://my.repourl.com/git-repo.git|grep abranch)
if [[ "${br}" != "" ]]; then
  git clone -b aBranch ...
fi
票数 1
EN

Stack Overflow用户

发布于 2018-11-23 19:09:38

我得到了与Kevin发布的git v1.7.1相同的行为--但是当使用git v2.12.0测试时,当指定了一个不存在的分支时,克隆命令确实失败了:

代码语言:javascript
复制
$ git clone --depth 1 -b FakeBranch --bare gitserver:/repo.git
Cloning into bare repository 'repo.git'...
warning: Could not find remote branch FakeBranch to clone.
fatal: Remote branch FakeBranch not found in upstream origin
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15393004

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档