I have a repository with a project in which I work alone, so I have no big issues forcing re-writing of history if really needed. Right now my history repo looks like:
(initial repo)
P (feature2)
/
A-B-...-C-D-E-J-K-M-N-O (develop)
| \ \
F-G-H-I-L (feature1)
Where ...
is a list of sequential commits I've omited in the graph, and K
and M
are merge commits from feature1 into develop. The issue is I've found a typo in my .gitignore and I can't really run the project if a clone the repo in another pc right now. The fix was introduced in two commits, N and O and I'd like to move N and O to their right places in time to be able to clone the project in any commit and be workable something like:
(moving the commits)
P (feature2)
/
A-N-B-...-C-O-D-E-J-K-M (develop)
| / /
F-G-H-I-L (feature1)
As you can see I would like to retain the merge structure from K
, M
, etc.
Ideally N
should be a fixup
of the initital commit A
, and O
a fixup
of commit C
:
(after squash/fixup)
P (feature2)
/
A*-B-...-C*-D-E-J-K-M (develop)
| \ \
F-G-H-I-L (feature1)
I've tried both --preserve-merges
or -i --rebase-merges
as I read related questions on SO and the git docs but have to go end up undoing it because it messes up more.
How would you proceed to achieve this?