Back to Blog
2025-04-15Abyan Dimas

Advanced Git: Rebase vs. Merge

Git Graph

Git is more than just commit and push. As projects grow, history management becomes vital.

The Merge Strategy

git merge feature-branch

  • Pros: Non-destructive. Preserves true history.
  • Cons: Creates "merge commits" that clutter the logs.

The Rebase Strategy

git rebase main

  • Pros: Linear history. Looks like you coded everything sequentially. Easier to read.
  • Cons: destructive. Rewrites history. NEVER rebase a public branch.

Cherry Picking

Sometimes you need just one specific commit from another branch, not the whole thing.

git cherry-pick <commit-hash>

This applies that specific change to your current branch. Useful for hotfixes.

Interactive Rebase

The ultimate cleanup tool.

git rebase -i HEAD~3

This lets you squash typos, reorder commits, and edit messages before pushing.

Share this article

Read Next