0

I want to merge all my existing merge requests manually. Let's say these are my existing merge requests:

1) feature1 --> master
2) feature2 --> master

For some business requirements, I need to merge all existing merge request branches to an intermediate branch called integration on my local. And then I need to merge integration with master..And on my workstation, what I'm doing is:

$ git clone ...
$ git fetch
$ git checkout master
$ git checkout -b integration

# Rebase feature1 with integration and merge
$ git checkout feature1
$ git rebase integration
$ git checkout integration
$ git merge feature1

# Rebase feature2 with integration and merge
$ git checkout feature2
$ git rebase integration
$ git checkout integration
$ git merge feature2

# Merge integration to master
$ git checkout master
$ git merge integration
$ git push origin master

But when I check merge requests on GitLab, I only see the first one as merged. Second pull request still open even if the merge is successful.

2
  • 1
    manually with a cron … job Well, if it's a cron job, it's hardly manually. grabbing all waiting merge requests, merge them How do you perform merge? Using git merge or Gitlab API? If it's git merge do you push merges back to Gitlab? Commented Apr 15, 2019 at 11:36
  • Sorry for misleading explanation. There are some more complex processes to determine which pull requests are waiting for merge. Actually, that part is not important, you can forget about the Jenkins job and imagine that I'm locally pulling all merge request branches to my workstation and merging them to a branch called integration-branch. After this, I'm merging integration-branch to master on my local repo. Lastly, I'm pushing integration-branch and master branches to GitLab. I'm not using GitLab API and handling all these operations with just git commands (like git merge). @phd Commented Apr 15, 2019 at 11:46

1 Answer 1

1

Rebasing feature2 on top of integration is most likely creating a situation where none of the commits on your feature2 branch end up in the integration branch.

Remember that rebase does not modify the existing commits, but replaces them with new commits.

Try this:

# Rebase feature2 with integration and merge
$ git checkout feature2
$ git rebase integration

# This will update your pull request so gitlab can detect the merge
$ git push origin feature2

$ git checkout integration
$ git merge feature2
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you. This is the correct answer. Unfortunately, after trying your solution I figured out another problem in my design. Merging of feature1 and feature2 to integration is happening in two different Jenkins job, parallelly. Because of this, when I rebase feature2 with the integration branch, feature1's commits may not be in the integration branch yet. But of course this is another story and your answer is definitely answering my first question. Thank you.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.