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.
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-reposo now your repo may have four branches:
master, bA, bB, bCI will create a branch from master called
f-merge-his-repogit checkout masterThis makes sure that f-merge-his-repo branches out from master.
git checkout -b f-merge-his-repoThis 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 bAgit merge bBgit merge bCIf 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 bCare now all inf-merge-his-repothen, just simply merge
f-merge-his-repointo your master branchYou should first switch to the master branch.
git checkout masterAnd then merge f-merge-his-repo
git merge f-merge-his-repoor if you prefer a none fast forward merge
git merge --no-ff f-merge-his-repoAfter all, delete these branches.
git branch -d bAgit branch -d bBgit branch -d bCgit branch -d f-merge-his-repoYou should really take a look at
pro-githere. 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 mergeandgit rebaseis likeMerge 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 mastergit merge their-branch --no-ffor
git merge their-branchAnd rebase is rebasing your current branch ON another branch(usually the main branch)
git checkout feature-branchgit rebase master