是否可以从命令行在纯 Git 中创建合并请求?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/7273434/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 11:45:14  来源:igfitidea点击:

Is it possible to create merge requests in pure Git from the command line?

gitgitoriouspull-request

提问by buley

I'm using a behind-firewall install of Gitorious.

我正在使用 Gitorious 的防火墙后安装。

I can go into the web application and create a pull request from a clone and target the master repo from which it was cloned.

我可以进入 Web 应用程序并从克隆创建拉取请求,并以从中克隆它的主存储库为目标。

I'd like to be able to do this on the command line. More specifically, I'd like to be able to open merge requests from the command line from one branch to another (rather than from clone to seed repo).

我希望能够在命令行上执行此操作。更具体地说,我希望能够从命令行打开从一个分支到另一个分支(而不是从克隆到种子存储库)的合并请求。

Since I'm not using Github, I can't use Github specific tools or libraries. Is this possible?

因为我没有使用 Github,所以我不能使用Github 特定的工具或库。这可能吗?

采纳答案by svick

There is no such thing as “merge request” in git itself. So, if this would be possible, it would require something specific to your git host.

git 本身没有“合并请求”这样的东西。所以,如果这是可能的,它需要一些特定于你的 git 主机的东西。

回答by eckes

The answer given by svickis not correct. It ispossible.

通过svick给出的答案是不正确的。这可能的。

There's git request-pullwhich is part of the Git suite. Using that command line tool, you could create a pull request that could be sent per E-Mail.

还有git request-pull这是Git的套件的一部分。使用该命令行工具,您可以创建可以通过电子邮件发送的拉取请求。

Example:
your originholds a branch master. Now you create a local bugfix branch fix, implement the bug fix and push that fixbranch to origin:

示例:
origin持有一个 branch master。现在您创建一个本地fix错误修复分支,实施错误修复并将该fix分支推送到origin

git push origin fix:fix

Then, you want someone to merge the changes made in the fixbranch into master. Create the pull request with

然后,您希望有人将fix分支中所做的更改合并到master. 创建拉取请求

git request-pull master origin

This will create a text formatted as follows:

这将创建一个格式如下的文本:

The following changes since commit <SHA of master>:

  <commit message of SHA of mster>

are available in the git repository at:
  <repo location> fix

<User Name> (<Number of Commits>):
      <messages of the commits>
      ...

 <changed files>
 ...
 <file statistics>


If the merge request shall go to somebody that cannot access your repo where you pushed your changes, there's always the opportunity of doing it with git format-patch.

如果合并请求将发送给无法访问您推送更改的存储库的人,那么总是有机会使用git format-patch.

After pushing your fixbranch to origin(you don't even need to do that), while being on the fixbranch create the patch using

在将您的fix分支推送到origin(您甚至不需要这样做)之后,在fix分支上创建补丁时使用

git format-patch master..

This will create a patch file for each commit you did in fixsince branching off master. You could bundle the generated .patchfiles with

这将为您在fix分支后所做的每个提交创建一个补丁文件master。您可以将生成的.patch文件与

tar czf fix.tgz *.patch

and then send to someone e.g. via E-Mail to review and apply.

然后发送给某人,例如通过电子邮件进行和申请。

For the sake of completeness: applying the patches could be done with git am.

为了完整起见:可以使用git am.

回答by Ali Zarezade

Gitlab add this feature from v11.10. After committing your final changes, instead of pushsimply use:

Gitlab 从 v11.10 添加此功能。提交您的最终更改后,而不是push简单地使用:

git push -o merge_request.create

to create a merge request. More details in push docsor merge request docs.

创建合并请求。推送文档合并请求文档中的更多详细信息。

回答by brauliobo

You may use this command line tool: https://github.com/brauliobo/gitorious-merge-request

你可以使用这个命令行工具:https: //github.com/brauliobo/gitorious-merge-request

./gitorious-merge-request -e [email protected] -s 'test' -r '~brauliobo/noosfero/brauliobos-noosfero' -a easysafeinstall -b master -t 'noosfero/noosfero'