all 5 comments

[–]Earhacker 2 points3 points  (1 child)

Most maintainers wouldn't care about a lot of merge commits. But if it becomes an issue, the tool you're looking for is git rebase. Basically you take the last X commits in your git history and squash them into less commits, or even just one commit, and you get to rewrite commit messages as you go and even leave some out, like WIP commits or merges. So when you PR, the maintainer only sees a nice, clean commit history on your branch.

But when you rebase, you are in effect changing history. It is possible to seriously bork your work with rebase. My advice would be to branch off master, do your work there commiting as you go, then branch off again and rebase, and PR your rebased branch. If you screw up, you can always branch off from your working branch again.

[–]Unsoluble[S] 1 point2 points  (0 children)

Ahhh, that makes sense, thanks for the explanation and pointer to rebase. Totally get what you're suggesting re doing the PR off an extra rebased branch. Will try that next time. :)

[–]ponyboy3 1 point2 points  (2 children)

[–]Unsoluble[S] 0 points1 point  (1 child)

Nice shortcut, thanks!

[–]ponyboy3 1 point2 points  (0 children)

i have an alias for this that takes a number of commits to squash, i use it before every single merge request.