I’ve since began using rebase to keep the git history linear when merging a feature branch and things are much cleaner now. But the original history of the repository is an absolute mess. We’re currently preparing for an open source release and so I’m going through polishing things like this before its getting shared with a much wider audience and this becomes way more disruptive of a thing to fix. The history looks like this:
* linear history since here
|
*72fa315
|
| *6472f3f
| |
| | *a1c2664
| | *060b2cf
| | *4712541
| * | d419e5b
| |/
* | 46fb47e
||
| *62f6912
* | 79573b1
||
| *31d7631
* | c8ce0f6
||
| *26cc06a
* | 2b17cf4
||
| *79faecd
| |
| | *a0b51f9
| | *d749c7f
| | |
| | | *61ef3d
| | * | 6abade
| | |/
| | *99ea517
| | *4a1710e
| | *b7a04f5
| | *8983b8b
| | *4d38477
| * | 6e0300b
| ||
| | *c23bbb1
| | *13e2936
* | | 19d47b1
|| |
| * | 56ba0b4
| ||
| | *f3e8707
| | *e1b8ff1
| |/
|/|
* | 8d532d9
||
| *b62572b
* | 44652a2
||
| *03cc916
* | 2e9a693
||
| *0a09c45
| |
| | *212067a
| | *cb8d65d
| |/
| *56a73d0
|/|
| *737d95a
|/
*753beab
|
| *01f6ae2
|/
*760b396
Now I have seen a few guides explaining how to go about this, however I am running into some issues. I figured I could approach this in stages and so the very first thing I’d like to try to do is to simply linearize those first 3 commits:
...
|
*753beab
|
| *01f6ae2
|/
*760b396
According to other posts I’ve read, I could use git rebase --interactive 760b396
and it seems pretty straightforward how that would work, however when I attempt to run this, I get presented
pick 01f6ae2
pick 737d95a
pick cb8d65d
...
which does not show any of the merge commits. I can obviously use git rebase --interactive 760b396 --rebase-merges
to show the merge commits, but I’ve been lead to believe this is error prone, and what I’m presented with is far less clear on how to work with:
label onto
# Branch develop
reset onto
pick 01f6ae2
label develop
# Branch geotiff-dev
reset onto
merge -C 753beab develop
label branch-point
pick 737d95a
label geotiff-dev
...
This post also covers a more manual approach. Following what it describes, I’ve tried:
git checkout 01f6ae2
git rebase 760b396
git cherry-pick 753beab..main
this fails with error:
error: commit 56a73d026c26a53a3c5d87dcbbbb932ca026a680 is a merge but no -m option was given.
fatal: cherry-pick failed
I’ve attempted to fix with:
git cherry-pick 753beab..main -m 1
and while this executes, it does not at all do what I am expecting. What I am expecting (and would ultimately like to see) is those first three commits becoming simply:
*753beab
|
*01f6ae2
|
*760b396