I am confused about why a GitHub pull request is showing lots of commits that I didn't make, when I have rebased directly off current master.
I did the following:
git pull
git checkout -b my-new-branch
Days pass while I work on stuff, then:
git add .
git commit -m 'Add my amazing commit'
Add a few more commits, then get ready to push:
git fetch
git rebase master
The rebase runs with no conflicts, so:
git push origin my-new-branch
However, when I open the branch on GitHub, it is showing my commits on top of 92 commits from other members of my team. Why is it showing these as different to master, when I have rebased off master?
OK, it was because I hadn't updated my local master, because I'd only fetched and not pulled. Doh!
I fixed this as follows. First I updated the local master:
git checkout master
git pull
Then I created a new branch off my up-to-date copy of master:
git checkout -b my-second-branch
Then I checked what the hashes of the commits I cared about on the old branch were:
git whatchanged my-new-branch
Then I cherry-picked in the commits I cared about off the first branch, onto the second branch:
git cherry-pick hashofmyfirstcommit
git cherry-pick hashofmysecondcommit
And then I pushed the new branch:
git push origin my-second-branch
And then I created a PR off that, and deleted the old branch and the old PR.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With