首页 文章

通过composer安装:功能分支结帐时多个git遥控器和pathspec错误

提问于
浏览
1

我正在使用composer和链接的git存储库安装我们的PHP应用程序 . 安装后,克隆的存储库配置了两个git遥控器,“composer”和“origin” .

composer.json

"require": {
    [...]    
  "mycompany/myrepository":       "dev-master",
}, 
[...]
  "repositories": [
{
  "type": "vcs",
  "url":  "git@bitbucket.org:mycompany/myrepository.git"
},

在作曲家完成安装之后:

$> git remote show
composer
origin

当我想切换到存储库上的任何可用功能分支时,它会因git错误而失败 .

$> git fetch && git checkout branchname 
error: pathspec 'branchname' did not match any file(s) known to git.

当我删除git remote'composer'时,它工作正常,但不是很可扩展/高效 .

$> git remote rm composer

我的composer.json或我希望实现的方式可能有什么问题?

编辑:当时基于https://getcomposer.org/doc/01-basic-usage.md创建了composer.json - 如果我刚开始并且只需要一个模块,没有依赖项等,然后执行 compser create-project ,结果是相同的:遥控器"composer"和"origin"都可用 .

更新:我尝试使用基于作曲家文档的单个git公共repo monolog / monolog做同样的事情,并且它产生了相同的两个遥控器 .

从头开始的测试用例:

{
  "require": {
    "monolog/monolog":       "dev-master"
  },

  "require-dev": {
  },

  "repositories": [

    {
      "type": "vcs",
      "url": "https://github.com/Seldaek/monolog"
    }
  ]
}

$ composer create-project
$ cd vendor/monolog/monolog
$ git remote show
composer
origin

1 回答

  • 1

    运行 git branch -a 以查看您拥有的分支 .

    它应该看起来像

    * master
    remotes/origin/master
    remotes/origin/branchname
    remotes/composer/master
    

    如果没有 local 分支 branchname 你可以

    git fetch origin
    git checkout --track origin/branchname
    

    origin 跟踪 branchname .

相关问题