gitrebasefixup

Is it possible to easily move all commits from one branch onto another as one commit?


I know, I can do an interactive rebase, reword first commit and fixup all other. But if a branch contains hundreds of commits it becomes very tedious.

Is there a simpler way?


Solution

  • You can use git merge --squash to squash the commits into a single one while merging into the branch.

    Switch to the target branch

    $ git checkout target-branch
    

    then use

    $ git merge --squash original-branch
    

    All the commits in original-branch will be merged into a single one, and applied to the target-branch.