Wednesday, 15 June 2011

git - How do I squash specific commits on a local branch? -



git - How do I squash specific commits on a local branch? -

i can find few answers out there come close want, i'm afraid i'm not experienced plenty git understand how accomplish want.

given local branch commits a-b-c-d-e-f-g-h-i-j on it, want crush of commits end with, example, equivalent of a-bcd-e-fgh-ij.

is possible? intention local branch, after rebasing, before merging master branch, in order create more concise , informative history.

you can rebase. assuming commits a-j on local branch branchname built on top of master, can this:

git checkout branchname git rebase -i master

you'll prevented interactive window this:

pick commit message pick b commit message b pick c commit message c pick d commit message d pick e commit message e ...

interactive rebase provides instructions scenario, should alter "pick" "squash" c , d (and same g, h , j):

pick commit message pick b commit message b crush c commit message c crush d commit message d pick e commit message e

this crush b, c , d single commit, allowing alter commit message.

if you're happy utilize commit message of b, can utilize "fixup" instead of "squash" , won't prompted update commit message.

git

No comments:

Post a Comment