gpt4 book ai didi

git - BitBucket 推送功能分支模型

转载 作者:太空狗 更新时间:2023-10-29 14:03:28 25 4
gpt4 key购买 nike

我在 bitbucket 服务器(私有(private)托管)上创建了一个新分支。 Bitbucket 有多种分支类型,如“修补程序”、“功能”等。我使用“功能”分支模型创建了一个。分支列表中的分支名称变为“feature/mybranchname”。我执行通常的 git fetchgit checkout -b mybranchname origin/feature/mybranchname 并开始工作。

但问题是我在分支“mybranchname”中所做的任何新更改都无法推送到远程。每当 git push 执行时,只有 master 会得到更新,即使 git status 显示 X 在“origin/feature/mybranchname”之前提交。

git push -u origin mybranchname 将在服务器上创建一个没有“feature”名称的新分支,因此它被复制到一个新分支中。

git push feature/mybranchname 将返回以下内容。

fatal: 'feature/mybranchname' does not appear to be a git repository
fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

```

找到 this类似的问题,但没有任何解决方案。找到this来自 atlassian 的文档说明什么是分支模型等,但没有提及如何推送给它们。

预期结果:来自“mybranchname”的本地提交被推送到远程的“feature/mybranchname”,而无需从 Web UI 进行 merge 。

最佳答案

您需要指定远程仓库:

gut push -u origin feature/mybranchname

然后你的本地feature/mybranchname将链接到其远程跟踪对象 origin/feature/mybranchname , 和一个简单的 git push就足够了。

OP 添加:

I created a new branch using git checkout -b mybranchname feature/mybranchname but instead it should be just git checkout feature/mybranchname

是的,因为 git checkout man page mentions :

git checkout <branch>

If <branch> is not found but there does exist a tracking branch in exactly one remote (call it ) with a matching name, treat as equivalent to

git checkout -b <branch> --track <remote>/<branch>

请注意,在这种情况下,您不需要 git push -u origin feature/mybranchname : 同样,一个简单的 git push就足够了,因为本地分支已经链接到远程跟踪分支。

关于git - BitBucket 推送功能分支模型,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50126401/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com