Saturday, 15 June 2013

git - Rebasing a branch that has been branched from -



git - Rebasing a branch that has been branched from -

i'm attempting cutting off part of history of repository can graft onto repository git replace described in this article.

the main difference between case described in article , repository is, master branch has existing branches. maintain layout of branches , branch-points equivalent after have cutting away history.

my history approximately looks this

cutting here | v o--o--o--o--o--o--o master \ \ \ \ \ o--o \ o--o--o b o--o--o c

there no branches off of master before "cut here" commit.

what want accomplish this:

o--o--o history initial tree @ cutting | v o--o--o--o--o master \ \ \ \ \ o--o \ o--o--o b o--o--o c

that means wouldn't sufficient rebase master on initial tree need replay existing branch on equivalent new commit after rebase of master. don't want replay branches on new master, because perchance have conflicts.

is there smart , automatic way this?

these commands have result looking for:

git checkout --orphan temp-branch cut–commit git commit // create new initial commit git rev-parse head // sha of commit git replace cut-commit new-commit git filter-branch -- --all

if have question regarding how , why works, sense tree leave comment. might want backup repo before stuff this.

from filter-branch docu:

note: command honors .git/info/grafts , .git/refs/replace/. if have grafts or replacement refs defined, running command create them permanent.

git version-control git-rebase

No comments:

Post a Comment