I would like to know how to insert a new commit (commit X) between 2 older commits, but (and this is the complicated part) I would like to do it before the "branching point" (in this case commit "B").
For example:
Before:
A -- B -- C <<< master
\
D -- E <<< branch
After:
new commit
|
|
A -- X -- B -- C <<< master
\
D -- E <<< branch
I have seen many good answers that work very well when there's no branch here :
- How to inject a commit between some two arbitrary commits in the past?
- https://blog.frankel.ch/inserting-new-commit-git-history/
But none of this options work when inserting a commit before the branching point, as they modify the rest of the tree "upstream" after the rebasing.
What is the best way to to this?
for context, the reason why I find myself frequently needing to do this is that when I start a new feature branch, I realise (after a few commits) that some changes should have been done earlier and on the master branch, instead of the new feature branch, like for example, modifying some .vscode files or some structural refactoring of the code that belongs more to the master branch, rather than the feature branch.
Is this the "right thing to do" in this case?