I like using the "rebase and merge" option for merging PRs in Github to avoid cluttering the commit history with merge commits.
But I've noticed the following behavior: (from Github's docs)
The rebase and merge behavior on GitHub deviates slightly from git rebase. Rebase and merge on GitHub will always update the committer information and create new commit SHAs, whereas git rebase outside of GitHub does not change the committer information when the rebase happens on top of an ancestor commit.
This seems strange to me since it's not how rebase works from the git CLI. Does anyone know why it behaves this way?
Ideally, I'd like to both a) avoid introducing merge commits and b) preserve the commit SHAs and tags from the feature branch. Is there a way to do this from the UI?
The Rebase Option But, instead of using a merge commit, rebasing re-writes the project history by creating brand new commits for each commit in the original branch.
When you select the Rebase and merge option on a pull request on GitHub.com, all commits from the topic branch (or head branch) are added onto the base branch individually without a merge commit. In that way, the rebase and merge behavior resembles a fast-forward merge by maintaining a linear project history.
Merge branchesGit creates a new commit (M) that is referred to as a merge commit that results from combining the changes from your feature branch and master from the point where the two branches diverged.
When you do rebase a feature branch onto master, you move the base of the feature branch to master branch's ending point. Merging takes the contents of the feature branch and integrates it with the master branch. As a result, only the master branch is changed. The feature branch history remains same.
Your appreciation is correct, that's not how rebase works in git. The reason is in GitHub some options are poorly named:
--no-ff
option (and even when the commit is up to date, a new commit will be introduced instead)And if you are using the "GitHub Desktop" application you should have seen other unfamiliar names like "Sync" instead of "Pull"+"Merge"+"Push".
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