Reputation: 5381
I created a branch called my_branch
and push it to Github. Now when I go to my repo on Github I see my_branch
listed under "Your recently pushed branches" and a green button on the right that says "Compare & pull request". I click on that. At the top it says "base:master <- compare:my_branch". I scroll down to the code changes below. I see a change in the README.md. On the left a line is highlighted in red that says "This is old". On the right the corresponding line is highlighted in green and says "This is new". My understanding is that the line on the left is master and the right is my_branch. But I didn't make that change; I'm guessing someone else did and updated master. Then (my guess is) I accidentally added it when switching back and forth between master
and my_branch
.
But even if I accidentally added it, I'm confused why "This is old" is showing up in master. So I go to the repo on Github and the README.md says "This is new". It says the same thing in my_branch
. I can't find anywhere that says "This is old" anymore.
I would like to create a pull request that takes the changes I made in my_branch
and adds them to master. But if I create this pull request it will include a bunch of stuff that I didn't write, and it will appear to be adding things to an old version of master. What did I do and how do I create the correct pull request?
Upvotes: 0
Views: 107
Reputation: 1067
Try pulling origin/master
into your my_branch
using the following commands:
git checkout my_branch
git pull origin master
The first one is to make sure you're in the right branch, then the second command will fetch and merge the latest from origin/master
in your branch.
Finally, push your branch my_branch
to GitHub:
git push origin my_branch
Now, if you go back to GitHub and try to create the PR again, everything from your branch should be up-to-date with your master in origin.
Upvotes: 2