Reputation: 473
I am in a bit of a situation regarding my dev branch having a different history than my master, despite both of them containing the same content due to a squashed merge.
On Github, I used the "squash and merge" option on my pull request from my dev
branch to master
. This has resulted in a separation between master
and dev
that doesn't actually exist. According to Github, my dev
branch is a number of commits ahead of master
despite those commits being squash-merged into master
.
Furthermore, the various merges I've done onto master
from dev
do not exist on dev
and thus dev
is also behind master
. Including a commit that exists on master
that I have not merged onto dev
because I know that will only make things worse.
How do I resolve this issue? Ideally, since both branches are in fact the same (except 1 commit on master
that should be ahead of dev
) how do I synchronize these branches?
I can update my question with more information if more is needed to help understand my tree.
UPDATE: I have found a similar problem here and I believe it is indeed the squash that has caused this confusion. I am afraid I will have to revert the merge and perform it again without squashing so that Github can correctly understand the history of the two branches.
I could alternatively squash the commits on the dev
branch itself and re-merge just the one commit, as I would prefer, but that sacrifices the history of the branch. I think I need to decide between one of these two approaches. Is there another way?
Upvotes: 1
Views: 546
Reputation: 1323433
I could alternatively squash the commits on the
dev
branch itself and re-merge just the one commit, as I would prefer.
If you do a PR from the pushed dev
branch to master
, and merge-squash it... then your local dev
should effectively be reset to the new master
state.
git fetch
git branch old-dev dev
git checkout -B dev origin/master
You can then go on from the new dev
branch
Upvotes: 2