If I understand your question correctly, no - this is not possible. Each commit points to its parent commit. Modifying a parent will cause all subsequent commits (even though the patch is the same) to be different. git rebase
handles that pretty well, but the following branch scheme will NOT be possible without merging the initial develop commit to master (which is not what I think you want):
o---o--o--o--o (branch master)
/|| || || ||\
o--o--o--o--o-o--o--o (branch develop)
When you change your initial commit, git will re-commit all the following commits (create a new hash for each commit), which will look like this:
o--o--o--o--o (branch master)
o--o--o--o--o--o--o (branch develop)
I don't understand why you need this, but git actually helps you save your history by using merges. When you merge, the history of the merged branch is merged with the merging branch, so after the merge you can clearly see what's going on with git log --graph
.
On the other hand, if you have different histories in 2 branches but the actual patches are the same (like in my second illustration), you can use git rebase
to make your history cleaner and linear, to look like this:
o--o--o--o--o (branch master)
\
o--o--o (branch develop)