![]() ![]() Squashing everything into one huge commit means it will be harder for other developers to follow your changes. A branch is the set of these changes that represents a feature. Commits should represent a meaningful set of changes. In this case I'm referring to cleaning up the history of a source tree by squashing commits. 158 1 12 Add a comment 2 Answers Sorted by: 3 One easy way to accomplish this without the possibility of conflicts, is by resetting (soft or mixed) to the nth commit, and then committing. In Vim, navigate to start of the line with the commit you wish to squash (with arrow keys or mouse), cw to delete pick and enter insert mode, f for fixup or s for squash, then ZZ to save and exit.Īs a side note, the link you gave suggests flatting your feature branch into a single commit. Git: Squash Multiple Commits into One Commit Scott Robinson One of the nice things about Git is its flexibility, allowing you to perform just about any task on a source tree that you'd need. ![]() The rebase settings will open in Vim, or whichever editor you set in the EDITOR environment variable. Rebase is a more general solution as in the same operation you can remove, re-order, and reword commits. Save and exit (ZZ in Vim), and rebase will do its magic. In your case, replace pick with s (for squash) or f (for fixup, which is a squash that drops the commit message of the squashed commit). This will allow you to modify the commits from master to your current branch. One of the most powerful and flexible tools for achieving this is the git rebase command. Assuming you have your branch checked out, and that it is branched from master, do git rebase -i master 5 days ago - When working with Git, developers often need to combine changes from different branches or even reorder and modify their commits. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |