Skip to content
Discussion options

You must be logged in to vote

what is the difference between git merge and git rebase. When would you use one over the other?

git merge
What it does: Creates a new merge commit that joins two branches together. The feature branch's history is preserved intact, and a merge commit records that the branches were combined.
History: Non-linear — you see the actual branching and merging pattern.
Safety: Non-destructive. Existing commits on either branch are never altered.
text
A---B---C feature
/
D---E---F-------G main ← merge commit G
git rebase
What it does: Takes the commits from your feature branch and replays them on top of the target branch, rewriting history as if you started working from the latest point.
History…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by sudoUgando
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants