Skip to content
Closed
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 14 additions & 17 deletions Tips And Tricks/git.txt → Tips And Tricks/Git merge or rebase.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Nice — here’s the commit graph diagram you asked for. This shows how your history looks depending on whether you merge or rebase.
This shows how your history looks depending on whether you merge or rebase.


Expand All @@ -10,11 +10,11 @@ Your branch: A──B──C──D──E─────────┴─M
Merge commit (M)

You branched from commit C.
You added commits D and E.
Upstream added commits after C.
When you git merge upstream/main, Git creates a merge commit (M) joining both histories.
History shows branching + merging — good for context but can look messy.
You branched from commit C.
You added commits D and E.
Upstream added commits after C.
When you git merge upstream/main, Git creates a merge commit (M) joining both histories.
History shows branching + merging — good for context but can look messy.


Expand Down Expand Up @@ -47,14 +47,14 @@ A──B──C──F──G──H──D'──E'

D) When to use what
Merge →
If you want to preserve the “real” history (showing when branches diverged).
Safer for beginners (no rewriting commits).
Good for long-lived feature branches.
Rebase →
If you want a clean, straight line history.
Preferred in open-source PR workflows.
Requires confidence resolving conflicts & force-pushing.
Merge →
If you want to preserve the “real” history (showing when branches diverged).
Safer for beginners (no rewriting commits).
Good for long-lived feature branches.
Rebase →
If you want a clean, straight line history.
Preferred in open-source PR workflows.
Requires confidence resolving conflicts & force-pushing.


Expand All @@ -75,12 +75,9 @@ git rebase upstream/main
# fix conflicts if needed
git push origin feature-branch --force-with-lease



So: Merge = “historical diary” (records exactly what happened).
Rebase = “rewrite the story” (makes it look like you developed cleanly on top).


Want me to also sketch a real-life example with commit hashes (like abc123, def456) so you can see how git log looks different between merge and rebase?