如何通过命令行在远程分支上执行Git拉取请求 [英] How to do a Git pull request on remote branches via the command line

查看:107
本文介绍了如何通过命令行在远程分支上执行Git拉取请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我感觉自己使用了错误的单词,或者误解了我正在使用的单词,这使得搜索我想做的事情变得困难.

I have a feeling i'm using the wrong words, or misunderstanding the words i'm using, which is making searching for what I want to do difficult.

现在我有一个Git存储库,其中3个分支托管在Azure Devops上(非常类似于Github/Gitlab/Bitbucket等).

Right now I have a Git repo with 3 branches hosted on Azure Devops (very similar to Github/Gitlab/Bitbucket etc).

我当前的流程是在本地提交并推送(使用PHP Storm),然后登录到Azure Devops,并手动使用其UI进行从我的 develop 分支到我的 staging的拉取请求分支.然后,我登录到服务器,并从 staging 分支进行git pull.

My current flow is to commit and push locally (using PHP Storm) and then login to Azure Devops and manually use their UI to do a pull request from my develop branch to my staging branch. Then I log into the server and git pull from the staging branch.

我总共有三个分支,分别是 develop staging production .

I have three branches in total develop, staging and production.

但是在我的本地计算机上,我只有 develop ,其他的仅存在于远程服务器上.我只是在 develop 中工作,并推送到 origin/develop ,然后从 develop staging 中进行拉取请求,然后然后准备好 production .

But on my local machine I only ever have develop, the others only exist on the remote server. I just work in develop and push to origin/develop and then do a pull request from develop into staging and then production when ready.

我认为必须有一种编写脚本来一次性完成所有这些操作的方法,而不必登录到Azure Devops或服务器.

I figure there must be a way to write a script to do all of this at once and not have to log into Azure Devops or the server.

总结我的问题尽可能简单:

To summarise my question as simply as possible:

我目前必须登录Azure Devops并执行以下操作:

I currently have to log into Azure Devops and perform the following actions:

  1. 登录到Azure Devops
  2. 点击分支
  3. 点击 staging 分支
  4. 旁边的新建拉取请求"
  5. 写一个提交消息(实际上标记为标题")
  6. 点击完成"
  7. 点击完成合并"

我想避免登录到Azure Devops,并能够通过命令行实现这一点.这可能吗?

I would like to avoid logging into Azure Devops and be able to achieve this via the command line. Is this possible?

我发现我基本上可以通过登录服务器并执行以下操作:

I've found I can basically do what I want by logging into the server and doing:

  • git pull (即使我正在分阶段,这也会拉动最新的开发成果
  • git merge origin/develop (这会将开发合并到本地暂存)
  • git push (这将更新远程登台)
  • git pull (this will pull the latest develop even though i'm in staging
  • git merge origin/develop (this will merge develop into staging locally)
  • git push (this will update the remote staging)

这是完美的,尽管一个缺点是似乎没有一种方法可以追踪 staging develop 相比有多远,这是由天蓝色的devops用户界面.

This works perfectly although the one downside is that there doesn't seem to be a way to track how far behind staging is from develop, something which is provided by the azure devops UI.

推荐答案

我发现我基本上可以通过登录服务器并执行以下操作:

I've found I can basically do what I want by logging into the server and doing:

git pull

(即使我正在分阶段,这也会拉动最新的进展

(this will pull the latest develop even though i'm in staging

git merge origin/develop -m我的提交消息"

(这将合并成本地开发阶段)

(this will merge develop into staging locally)

git push

(这将更新远程登台)

您还需要在本地进行开发,才能使其正常工作.

You need to have develop locally as well for this to work.

这篇关于如何通过命令行在远程分支上执行Git拉取请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆