Merge Pull Request Manually

2.5k views Asked by At

So I have following situation in github.

  1. I created a fresh branch from the mainbranch and named as userstory1

  2. I pushed my changes in branch userstory1 and raised a pull request to my colleague

  3. He saw that folder structure was not correct so renamed my code folder in mainbranch. So now I have folder mycode on userstory1 branch whereas on mainbranch its named my-code. My changes on branch userstory1 are yet to be merged to mainbranch

  4. Of course now automatic merge of my pull request is not possible on mainbranch

What is the best way to handle this situation? I want to use the same pull request for merging changes on branch userstory1 to mainbranch

What I have thought of is to get the code from mainbranch onto my machine and commit it to branch userstory1 but not sure if same pull request can be used if I do more commits on userstory1 branch

2

There are 2 answers

1
AudioBubble On BEST ANSWER

There are many ways First Is

checkout userstory1

git checkout userstory1

Now merge mainbranch

git merge --no-ff mainbranch

It will show you the conflict. To see clearly type

git status

and pay attention for the files that are changed on both side.

Now resolve the conflict manually and then type

git commit

If you want to add message it's upto you other wise it will ammend to previous one

then push the code

git push origin  userstory1

assuming origin as remote url.

No need to do anything with pull-request it will automatically updated.

0
larsks On

The best way to solve this is to update your local copy of the main branch, rebase your changes on top of this, and then push them (with -f) back to github.

This will update your pull request, which having been rebased on the main branch will be merge-able automatically.

This document seems to have a lot of good detail on the process.