Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Merging pull requests together

Tags:

Someone has submitted a set of pull requests to my repository on github. Unfortunately they've done this in several pull requests (one for each file) rather than submitting all the pull request for all the files in one go.

After requesting him to merge them as one - and not getting any response I'm now trying to merge these pull requests together myself in the Git Bash - but having little luck - I'm quite happy using the merge buttons and making commits through the GitHub program on windows but little more. I have no real understanding of the git shell - so if someone could go through the process of how I can merge these pull requests together (none of them conflict in anyway) it would be much appreciated.

like image 966
George Wilson Avatar asked Jan 18 '13 02:01

George Wilson


People also ask

What does it mean when a pull request is merged?

A pull request – also referred to as a merge request – is an event that takes place in software development when a contributor/developer is ready to begin the process of merging new code changes with the main project repository.

How do I merge two pull requests in bitbucket?

Once you are ready to merge a pull request, and when the reviewers have approved it, click Merge at the top right of the pull request view. You can merge a pull request if you have write (or admin) permission on the project.


1 Answers

Say if you have 3 pull requests A,B,C which are on three branches bA,bB,bC. and your main branch is master.

First get all of his branches to your local repo without merging it. git fetch his-repo

so now your repo may have four branches: master, bA, bB, bC

I will create a branch from master called f-merge-his-repo

git checkout master This makes sure that f-merge-his-repo branches out from master.

git checkout -b f-merge-his-repo This creates the branch f-merge-his-repo and switch to it.

So now you are currently on f-merge-his-repo, use the following commands:

git merge bA

git merge bB

git merge bC

If there are conflicts you should fix it(manually or using a mergetool), but as you said there are no conflicts, so we say that bA bB and bC are now all in f-merge-his-repo

then, just simply merge f-merge-his-repo into your master branch

You should first switch to the master branch. git checkout master

And then merge f-merge-his-repo git merge f-merge-his-repo

or if you prefer a none fast forward merge git merge --no-ff f-merge-his-repo

After all, delete these branches.

git branch -d bA

git branch -d bB

git branch -d bC

git branch -d f-merge-his-repo

You should really take a look at pro-git here. It is a simple book which shows you everything you need with git in your daily work, and believe me, once you get used of git bash, you will find all of these git GUI's frustrated(except viewing the log, I use gitk to view and analyse the log)

Last tip:

A good way to remember git merge and git rebase is like

Merge is merging another branch TO your current branch (of course you can name both branches, but the default syntax is merge the branch to your current branch)

so you should always switch to the main branch and merge others branch

git checkout master

git merge their-branch --no-ff or git merge their-branch

And rebase is rebasing your current branch ON another branch(usually the main branch)

git checkout feature-branch

git rebase master

like image 86
shengy Avatar answered Nov 27 '22 15:11

shengy