git rebase - When git rebasing two branches with some shared history, is there an easy way to have the common history remain common? -


suppose have following revision graph:

a-x-z--b      \       \-c 

with preceding both b , c. further suppose rebase upstream, creating new commit a*, , rebase both b , c onto a*. resulting revision graph following:

a*-x'-z'-b  \   \-x"-z"-c 

note shared history no longer shared. there simple way fix this, other than, say, rebasing b , rebasing c onto z' explicitly. in other words there better way automatically rebase multiple branches @ same time in order preserve shared history? seems little bit awkward have either artificially place tag @ split point, or manually inspect graph find out sha1 of commit on rebase c keep shared history, not mention opening possibility of mistakes, since have every time rebase until check changes upstream branch.

git rebase --committer-date-is-author-date --preserve-merges --onto a* c git rebase --committer-date-is-author-date --preserve-merges --onto a* b 

this should keep common commits having same sha1 , merges preserved. preserve merges not required in case, become issue less trivial history.

to branches contain in history do:

git branch --contains | xargs -n 1 git rebase --committer-date-is-author-date --preserve-merges --onto a*  

hope helps.

update:

this may cleaner syntax:

for branch in $(git branch --contains a); git rebase --committer-date-is-author-date --preserve-merges --onto a* $branch; done 

Comments

Popular posts from this blog

php - What is the difference between $_SERVER['PATH_INFO'] and $_SERVER['ORIG_PATH_INFO']? -

fortran - Function return type mismatch -

queue - mq_receive: message too long -