如何在不使用GUI的情况下使用Git CLI打开拉取请求 [英] How do I open Pull Request using Git CLI without using GUI
问题描述
以下是如何在Bitbucket上执行此操作的示例:手动创建Git叉.我可能会使用他们的命令行API在Bitbucket上创建项目,但至少需要阅读根项目权限.
Here’s an example of how to do this on Bitbucket: Manually create a Git fork. I may use their command line API to fork a project on Bitbucket, but I need to at least read the root project permissions.
语法如下:
curl -v --user {username}:"{password}" \
https://bitbucket.org/api/1.0/repositories/{accountname}/{repo_slug}/fork \
--data "name=mynewrepo"
要将名称为 Project D 的 Project A 从帐户 B 分支到我的帐户 C ,我将使用以下命令:
To fork Project A from an account B to my account C with the name Project D, I will use the following command:
-
curl -v-用户XYZ:"XYZPASSWORDXYZ";\ https://bitbucket.org/api/1.0/repositories/ABC/ProjectABC/fork \ --data" name = ProjectXYZ"
curl -v --user XYZ:"XYZPASSWORDXYZ" \ https://bitbucket.org/api/1.0/repositories/ABC/ProjectABC/fork \ --data "name=ProjectXYZ"
现在,我将这个项目克隆到我的本地计算机上, git clone [project]
Now, I will clone this project to my local machine, git clone [project]
我将转到项目目录并添加远程上游,该远程指向源存储库: git remote添加上游[git]
I will go to my project directory and add remote upstream which will point to the source repository: git remote add upstream [git]
现在,随时可以从源存储库(例如从master分支)中提取更改,我将使用: git pull上游master 并将本地提交推送到目标存储库上服务器,我将使用: git push origin master
Now, at anytime to pull the changes from source repository (say from master branch), I will use: git pull upstream master and to push my local commits to my target repository on server, I will use: git push origin master
当目标存储库上的更改准备好与源存储库合并时,请从Bitbucket网站或使用
And when your changes on target repository are ready to be merged with the source repository, create a Pull Request either from Bitbucket website or using Bitbucket API: Pull Request
但是,如果您要计算执行此操作的时间,则系统运行缓慢可能需要30秒到2分钟.我的观点是,有没有一种方法可以仅使用1条命令发送拉取请求",而无需使用所有这些东西就可以完成所有请求?
However, if you will calculate your time doing this stuff, it can take 30 seconds to 2 minute if you have slow system. My point is, is there a way to send Pull Request using only 1 command that will do it all without all this stuff?
推荐答案
我通过遵循 gh pr create
I solved it, by following the documentation given from GitHub CLI Manual. It is so easy to create a Pull Request by using the command line: gh pr create
这篇关于如何在不使用GUI的情况下使用Git CLI打开拉取请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!