GitLab 如何将更改推送到与非主分支不同的远程分支?

水银0114

我的分支dev_match_test是对分支的更新origin/dev

我想将dev_match_test分支的本地更改发送到远程存储库,

使得合并请求合并dev_match_testdev以后可以批准。

git status 命令说:

On branch dev_match_test
Your branch is ahead of 'origin/dev' by 22 commits.
    (use "git push" to publish your local commits)

git push返回错误:

fatal: The upstream branch of your current branch does not match
the name of your current branch.  To push to the upstream branch
on the remote, use

    git push origin HEAD:dev

To push to the branch of the same name on the remote, use

    git push origin dev_match_test

尝试两个建议的选项都没有好处:

git push origin HEAD:dev

返回错误

remote: GitLab: You are not allowed to push code to protected branches on this project.

我怀疑这是因为我试图将更改推送到dev我没有权限。相反,我想推到dev_match_test.

git push origin dev_match_test

只返回一条消息Everything up-to-date,什么都不做。

问题:如何将本地更改推送到dev_match_test分支?

索伦卡拉姆

最简单的方法是简单地从您所在的当前分支创建一个新分支,推送到远程,然后将新分支合并到 dev 中。

  1. 从当前分支创建一个新分支:

git checkout -b newBranchName

  1. 推送到远程:

git push -u origin newBranchName

  1. 在 GitLab 中,为 newBranchName 创建一个合并请求到 dev

请注意,这并不能解决您的分支 dev_match_test 未正确推送到远程的问题。为了解决这个问题,更多的信息会有所帮助。我怀疑分支 dev_match_test 设置为从 origin/dev 而不是 origin/dev_match_test 跟踪。如果您可以发送git remote -v(请隐藏网址)的输出,那可能会有所帮助。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何将主分支复制为开发分支并将其推送到 gitlab 而不进行更改

GitLab-CI在部署时将分支推送到远程

如何在Gitlab上推送到远程git分支?

将更改从克隆推送到 github 中的主分支 gitlab clone vs fork vs branch

远程:GitLab:不允许将代码推送到该项目上受保护的分支

如何将功能分支中的文件推送到远程的主分支?

如何将Android Studio项目推送到远程GitLab存储库

如何将更改推送到分支?

如何将最新的项目文件从 Git 推送到 Gitlab?

如何阻止推送到远程主分支

Gitlab:如何在Eclipse Git插件中将代码推送到我的分支中

如何使用命令行将分支推送到gitlab

更改gitlab中的默认分支

如何使用非主分支将子树推送到heroku

gitlab - 僅為非主分支運行管道

git,如何将本地分支推送到特定的远程

如何将分支推送到单独的远程仓库中?

如何在Gitlab中为非主分支的Web界面制作管道?(运行管道按钮)

如何提交和推送跟踪和取消跟踪文件的更改以在 gitlab 中更正分支

Gitlab没有推送分支,访问被拒绝?

如何将分支更改推送到 Git Repo?

GitLab 中的分支保护

在Gitlab中分支的Webhooks

当有人推送到主远程仓库(gitlab)时,如何更新镜像的远程存储库(自己的服务器)?

如何将主分支推送到另一个分支?

如何将本地Git分支推送到远程的master分支?

将功能分支推送到远程存储库以与不同步的主服务器合并

Git将主分支推送到辅助远程

Git:将代码推送到远程主分支