git - change exist commit to current commit -
this question has answer here:
- git rebase basics 2 answers
simply, i've done :
a------b-------c \ \ b2 now, want change b b2.
a------b2-------c is possible?
solution history:
i added work history.
$ git log commit b671c70b c commit f4acdc2b b commit 56f38939 $ git checkout f4acdc2b and modified something... committed -amend option.
$ git commit -amend $ git log commit e2fd729 b' commit 56f3893 now, became this:
a------b-------c \ \ b' to rebasing b b'
$ git checkout b671c70b $ git rebase -i 56f38939 which opens interactive editor
pick f4acdc2b b pick 56f38939 just remove line pick f4acdc2b, save , quit.
if there error error: not apply b671c70b... c, edit merge conflicts , then,
$ git add . $ git rebase --continue $ git log commit 914c6bc c' commit 56f3893 $ git checkout 914c6bc $ git rebase e2fd729 $ git log commit 5c65190 c'' commit e2fd729 b' commit 56f3893 now, looks this.
a------b'-------c''
you interactively rebase branch on top of b2 (on top of a actually, since want b2 gone):
git checkout yourbranch # references c) git rebase -i # drop b that give:
a------b2'-------c' (note c' c different sha1, since parent has changed)
(same comment b2, since parent changed)
Comments
Post a Comment