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

发布于 2024-12-02 15:47:07 字数 316 浏览 8 评论 0原文

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

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

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

由于我没有使用 Github,因此无法使用 Github 特定工具或库。这可能吗?

I'm using a behind-firewall install of 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.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

装迷糊 2024-12-09 15:47:07

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

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

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

git push origin fix:fix

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

git request-pull master origin

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

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>

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

fix 分支推送到 origin 后(您甚至不需要这样做),在 fix 分支上使用以下命令创建补丁

git format-patch master..

这将为您自分支 master 以来在 fix 中所做的每次提交创建一个补丁文件。您可以将生成的 .patch 文件捆绑在一起

tar czf fix.tgz *.patch

,然后通过电子邮件等方式发送给某人以供审核和应用。

为了完整起见:应用补丁可以通过 来完成git am

The answer given by svick is not correct. It is possible.

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

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

git push origin fix:fix

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

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.

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

git format-patch master..

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

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.

北座城市 2024-12-09 15:47:07

Gitlab 从 v11.10 开始添加此功能。提交最终更改后,只需使用:

git push -o merge_request.create

创建合并请求,而不是 push。更多详细信息请参阅 push 文档合并请求文档

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

git push -o merge_request.create

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

时光礼记 2024-12-09 15:47:07

您可以使用此命令行工具: 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'

You may use this command line tool: 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'
拒绝两难 2024-12-09 15:47:07

git 本身不存在“合并请求”这样的东西。因此,如果这是可能的,则需要特定于您的 git 主机的东西。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文