Git how to merge without a merge commit, but preserving hashes (to have a straight graph line in the git log)

So I have 2 branches - develop_1 and develop_2.
The first one needs to be merged into the second (let's say there are 3 commits in develop_1 which needs to be in develop_2).

I know there are merging strategies like merge and rebase.
Merge will preserve commit hashes but will create another merge commit and the git log won't be so clean in this case.
Rebase will make the git graph beautiful but will change commit hashes, so next time when I'll compare these two branches, it will still show the difference (while code changes actually are merged and actually develop_1 branch is fully merged into develop_2).

I tried to cherry-pick needed commits - hashes are changed. Patch also changes hashes.

Is there a way to do this clean - don't create a merge commit, have a straight line in the git graph, and have the git system (Github) don't show a difference between branches in the future?

Read more here:

Content Attribution

This content was originally published by Goltsev Eugene at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: