Team FAQ: this question comes up often, so we've answered it below. Add your own experience, or a different view, in the comments.
GitHub offers "Create a merge commit", "Squash and merge" and "Rebase and merge". What's the difference, and which one should a team use?
All three get your changes into
main. They differ in what the history looks like afterwards.mainmain, no merge commitA sensible default for most teams: squash and merge. One pull request becomes one commit, which makes
git log,git revertandgit bisecteasy. Use the PR title as the commit subject.On your own branch,
git rebase main(orgit pull --rebase) keeps your branch up to date without extra merge commits.The one rule that matters: never rebase or force-push a branch that other people are working on. Rebasing rewrites commits, and their copies will no longer match. If you must update your own PR branch after rebasing, use
git push --force-with-lease, which refuses to overwrite commits you haven't seen.Whatever you choose, pick one as a team and set it in the repo settings (Settings > General > Pull Requests) so everyone does the same thing.
What does your team use, and has it caused any problems?