git merge - Git reset (not hard) then fast forward merging of certain commit -
the case: branch commit1 -> commit2 -> commit3 -> commit4
the head in commit4.
i reset (not hard) commit1 , use commit1 base implement whatever changes done in commit4.
so end result is: commit1 -> commit4
is there git command that? or should rollback commit1 , implement changes done in commit4 manually?
thanks!
it is clear me, based on question, want commit sequence read:
... <- c1 <- new-c4 <-- branch
(remember, arrows point towards past history, not forward future).
it's not clear me whether want new commit (which call new-c4
above) keep source way in old c4
, or whether want discard changes made in c2
, c3
while keeping changes made in c4
.
you can achieve latter result using git rebase
, keep in mind usual caveat should never rebase published commit. make happen, run:
git rebase -i head~4
this bring editor session can keep or discard specific commits. see answer linked in martin konecny's comment, or barry gackle's answer.
if want keep changes introduced c2
, c3
while discarding commits themselves, git reset --soft
followed git commit
correct method. see vonc's answer here.
Comments
Post a Comment