Merging a dev branch shows lots of very old commits

Hi, I’m trying to merge the “dev” branch to “master” branch but when creating a pull request, it contains many, many old commits.

I used to follow the steps outlined in but I wonder if there’s a better way to fix this mess once and for all. Ideally, I just need to create a pull request to base master and compare dev branch on GitHub. Plain and simple. It should technically show the commits since the last time I did the merge, shouldn’t it?

Thanks in advance!

As long as there haven’t been any rebases or similar actions, yes. For example, if your last merge was a rebase merge it has recreated the merged commits, so they technically aren’t the same, and will be merged again unless you modify your dev branch to be based on the rebased commits. Similar for squashed commits, or any rebases outside Github.

Thanks for your reply. I think my question really is “how to make my master branch the same as my dev branch” from now on. Now that the two branches are so different, how should I proceed?

To simply rename these two branches is the last resort, I suppose.

Well, it depends on whether you are okay with force-pushing and the associated issues or not. If not, you’ll have to merge and resolve any conflicts in favor of the dev branch.

If you are okay with force-pushing and losing everything that’s different from dev on the master branch, you can use git reset [<mode>] [<commit>]:

This form resets the current branch head to <commit> and possibly updates the index (resetting it to the tree of <commit>) and the working tree depending on <mode>.

So, you can do something like this:

git checkout master
git reset dev
git push --force origin master

Obligatory warning: If you do this, you will lose anything that’s only on the current master, and everyone who has cloned the repository will get a warning when fetching. :warning:

1 Like