3 ms·
Learning git here. Could you please explain how rebase squashes commit ? Looking at man git-rebase it seam that it detaches a branch and attaches it to the curr
by chmike 13y ago
Learning git here. Could you please explain how rebase squashes commit ? Looking at man git-rebase it seam that it detaches a branch and attaches it to the current branch. From the documentation the chain of commits is preserved and simply moved in the graph. The sequence of commit nodes of the branch are not merged into one commit node.
- crististm 13y agoIf you work on a feature branch originating from master, what you do is "git rebase -i master" to squash your commits.
- Ygg2 13y agoIf you use rebase interactive like this: git rebase -i HEAD~n Where n is number of commits from HEAD, you can do ANYTHING to your branch. You can stop mid rebase to add some files that didn't exist before, squash, fix, execute commands, etc. You can even change order of commits and delete commits from history. BE VERY, VERY CAREFUL! https://www.kernel.org/pub/software/scm/git/docs/git-rebase.html https://www.kernel.org/pub/software/scm/git/docs/git-rebase.... (See interactive mode and splitting commits).
- praptak 13y agoIn addition to the other responses (i.e. 'rebase -i'), there's also the shortcut of passing the '--squash' option to the final 'merge' command. This, unlike the standard 'merge' does not create a commit but instead applies all the commits from the merged branch into your working tree. You can then review the changes and create the commit yourself.