🧬 Rebase & Advanced Flow: Cherry-pick and Rewriting History

Rebase & Advanced Flow: Cherry-pick and: Rebase and cherry-pick are both time-machine tools that rewrite WHERE a commit sits in history, but they answer two different questions:

Rebase and cherry-pick are both time-machine tools that rewrite WHERE a commit sits in history, but they answer two different questions: rebase asks "what if my whole branch had started from a later point in time?" and replays every one of your commits on the new base, while cherry-pick asks "can I copy just this ONE change elsewhere, without dragging its neighbors along?" and applies a single commit's diff as a brand-new commit somewhere else. The thought-provoking question: if merge already exists and preserves the true history, why would a team ever choose to rewrite commit hashes with rebase at all? Because a history full of "fix typo" and "oops" commits on a shared branch is not honesty, it is noise — rebase lets you present the story as it should have been told, one clean logical commit at a time, before anyone reviews it. Java analogy: rebase is like regenerating a Gradle/Maven dependency tree after changing a version — every downstream artifact gets recalculated against the new base, exactly like every commit's hash changes once the base commit changes; cherry-pick is closer to copying one compiled class out of someone else's JAR into your own project, without pulling in the rest of that JAR's history. In real QA work, this is precisely why a hotfix branch pulls in ONE specific bug-fix commit with cherry-pick instead of merging an entire in-progress feature branch that might also carry untested, unrelated changes — and why rebasing a branch a teammate has already pulled can silently break their local history unless the whole team explicitly agreed to it first.

Find the exact commit, then switch to the target branch

What Does git log feature/hasan --oneline -5 Actually List?

git log feature/hasan --oneline -5 shows…

git log feature/hasan --oneline -5 shows the HISTORY of the feature/hasan branch, NOT the branch you're currently on — you can LOOK at another branch's commits WITHOUT checking it out.

The --oneline flag compresses…

The --oneline flag COMPRESSES each commit into ONE line (short hash + message), and -5 shows ONLY the LAST 5 commits — this lets you SCAN a large history quickly.

A short hash like d4e5f6a in the list…

A short hash like d4e5f6a in the list is a UNIQUE FINGERPRINT of that commit's FULL content (diff, author, message) — you'll PASS this hash to cherry-pick in the NEXT step.

Running git switch hotfix/release-1.4…

Running git switch hotfix/release-1.4 CHANGES the ACTIVE branch — the NEXT command (cherry-pick) will ADD a new commit ON TOP OF this branch, feature/hasan stays UNAFFECTED.

The ORDER of these two steps matters…

The ORDER of these two steps matters: FIRST FIND which commit to move, THEN SWITCH to the target branch — reversing the order risks searching for the hash while on the WRONG branch.

Order the first steps for targeting a single commit on another branch.