Git: Merge vs rebase
A short, tested Git example for merge vs rebase. Copy it and adjust the names and paths for your project.
Git
git switch feature
git merge main # keeps history, adds a merge commit
git switch feature
git rebase main # replays your commits on top of mainRebase gives a linear history but rewrites commits. Never rebase commits others have pulled.
Find it in Zest
Search for “git merge vs rebase” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.