On Sun, 20 Nov 2016 18:59:48 -0800 (PST) Charlie Oehlrich <charlieloehlr...@gmail.com> wrote:
> it is actually like this > > branch-1 is the 1st line > > branch-2 is the 2nd line > > master is the 3rd line > > A--B--C--D > > E--F--G--H--I > > J--K---L--M > > and i want it to do this > > A--B--C--D > > E--N > > J--K---L--M > > and N is F, G, H and I combined Yes, you have a terminological problem: in all the SCM systems I'm familiar with the term "merging" means something else. What you want is called "squashing" in Git. So you actually want to squash commits F..I to a single commit, N. To do this, you have two options: rebasing and "squash merging". With rebasing you do git checkout branch-2 git rebase -i E and then in the rebase script you'll be presented with you change the commands for all the commits except the first one from "pick" to "squash" or "fixup". Specifying "squash" will add that commit's message to the commit message of its preceding commit while "fixup" does not use the commit's message at all. With merging, you do git checkout E git merge --squash branch-2 git commit git checkout -B branch-2 Here, 1. The second command moves you to the so-called "detached HEAD" state -- when you're not on any branch, but the commit E is checked out and HEAD points at it. 2. The second command picks all commits reachable from branch-2 excluding those reachable from E (F..I in your case), squashes them and leaves these changes ready to be committed. 3. So you commit them -- recording a new commit and moving HEAD forward to point to it. 4. You overwrite the branch "branch-2" to point to HEAD, and check it out. There are alternatives to it, if you don't need that branch checked out: git branch -f branch-2 or even git push -f . HEAD:branch-2 -- You received this message because you are subscribed to the Google Groups "Git for human beings" group. To unsubscribe from this group and stop receiving emails from it, send an email to git-users+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.