参考/远程/起源/开发"存在;无法创建"引用/远程/源/开发/主" --标签推送到所有分支



我在bitbucket中创建了一个新的存储库。

从我的本地文件夹我做了:

git remote add origin https://......
git push -u origin master

所以,我的项目上传到了bitbucket。

然后,我从bitbucket创建了另外两个分支,开发和发布。

然后我做了:

git fetch origin development

然后是git branch --set-upstream-to=origin/development,因为我想推进开发分支。

git status -sb
## master...origin/development

然后git remote add origin/development https://..添加开发分支。

最后:git push --tags origin/development master将标签推送到开发分支。

正如我所看到的,它推送了所有分支(master和development)中的标签,尽管我只选择了development。

现在,来自上述命令的完整信息是:

Counting objects: 1, done.
Writing objects: 100% (1/1), 170 bytes | 0 bytes/s, done.
Total 1 (delta 0), reused 0 (delta 0)
To https://bitb....
* [new tag]         show -> show
* [new tag]         v1.0.0 -> v1.0.0
error: update_ref failed for ref 'refs/remotes/origin/development/master': cannot lock ref 'refs/remotes/origin/development/master': 'refs/remotes/origin/development' exists; cannot create 'refs/remotes/origin/development/master'

所以说remotes/origin/development存在,而remotes/origin/development/master不存在。

我不明白它为什么要搜索那个。

您也可以使用删除ref

git update-ref -d refs/remotes/origin/development

此步骤:

Then git remote add origin/development https://.. to add the development branch.

是错误的:它添加了一个名为origin/development的新远程,这不是一个好主意,因为您已经有了一个名称为origin的远程。

remote只是一个URL的短名称,您的Git可以在该URL上联系另一个Git。据推测,您的所有分支都指向Bitbucket上的同一单个Git URL,您只需将其称为origin

git pull命令使这一点特别令人困惑,因为它充满了历史上的奇怪之处。我建议你避免。一旦你避免了git pull——不管怎么说,这只是一个方便的快捷方式——剩下的项目就更有意义了:origin只是你的Bitbucket URL的一个短名称,你git push origin development可以在那里推送development。当你从origin中获取时,你的Git会重命名你从他们的Git中获得的内容,这样他们的master就变成了你的origin/master,他们的development就变成了origin/development。这里的origin部分来自远程名称,/master/development部分来自分支的名称,如他们的(Bitbucket的)Git存储库中所示。

最新更新