43

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?

Community
  • 1
  • 1
buley
  • 24,595
  • 17
  • 76
  • 99

4 Answers4

87

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.

Community
  • 1
  • 1
eckes
  • 56,506
  • 25
  • 151
  • 189
  • 3
    You seemed to have missed the actual question and only answered the title... It clearly states the pull request needs to go on Gitorious, which has its *own* pull request mechanism. – Idan K Sep 03 '11 at 14:01
  • 7
    This doesn't change the fact there is no concept of “merge request” in git itself. – svick Sep 03 '11 at 14:25
  • 10
    @Idan: The OP asks for a **command line** way to open merge requests. And that's exactly what I'm describing. – eckes Sep 05 '11 at 06:49
  • 3
    @eckes this don't create a merge request under the web interface. instead it generates patches and description for a email pull request, like LKML. this is not a gitorious merge request. – brauliobo Sep 06 '12 at 11:39
  • Note that "merge request" is a different name for "pull request" http://stackoverflow.com/a/29951658/2650732 – wojjas Nov 09 '16 at 11:32
17

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.

mrroot5
  • 1,254
  • 3
  • 21
  • 29
Ali Zarezade
  • 789
  • 6
  • 20
5

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

./gitorious-merge-request -e brauliobo@gmail.com -s 'test' -r '~brauliobo/noosfero/brauliobos-noosfero' -a easysafeinstall -b master -t 'noosfero/noosfero'
brauliobo
  • 4,548
  • 4
  • 25
  • 32
3

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.

svick
  • 214,528
  • 47
  • 357
  • 477
  • As git updated, this selected answer is not valid anymore. See my answer below. – Ali Zarezade Feb 18 '20 at 12:25
  • 1
    @AliZarezade AFAICT, that's still depending on where you're pushing to, it's not something git itself understands. But it's definitely much closer than eckes' answer and so I have upvoted your answer. – svick Feb 19 '20 at 09:40