I made a few commits in a local repo, pushed those to the remote and created a Pull Request to the upstream master. Those commits were squashed when the PR was merged.
$ git commit A
$ git push origin master
$ git commit B
$ git push origin master
Create PR, squash and merge into upstream master
Then when I do ...
$ git pull upstream master
It does a merge instead of a fast forward since the commit is different. How do I update my local repo to match the upstream master history after commits have been changed/squashed upstream?
I ended up doing the following ...
$ git reset HEAD~2 --hard
$ git pull upstream master
$ git push origin master --force
To match my history, but I'm hoping there's a much cleaner way to do this.
If you don't have any local changes you wanna save, you can just reset your local branch to match the remote.
First, get the new data from remote with
git fetch upstream
Second, after double checking that you are in your local master branch
git reset --hard upstream/master
That would reset your local branch to match the one at the remote.
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