Git Topics (9)Tap to view
    Git·Version Control·Topic 5 of 9

    Git Rebase & Cherry-Pick

    Reorder commits, merge records interactively (Squash), and move specific commits across branches.

    1. Rebasing and Cherry-Picking

    1. git rebase <branch>

      What it doescommits reverts the current branch above the top of the target branch for a clean linear history

      When to use itto update the feature branch with the latest main modifications without creating an additional merge commit

      Examplegit rebase origin/main

    2. git rebase -i HEAD~3

      What it doesInteractive refactoring of the last 3 commits (modify messages, squash, or delete)

      When to use itto clean up and organize the modification history before creating a Pull Request

      Examplegit rebase -i HEAD~3

    3. git rebase --continue

      What it doesContinues the Rebase operation after resolving conflicts in the current step

      When to use itAfter resolving a file conflict and adding it with git add

      Examplegit rebase --continue

    4. git rebase --abort

      What it doesCancels the current Rebase operation completely and returns to the previous original state

      When to use itWhen you encounter conflicts that you do not want to resolve right now

      Examplegit rebase --abort

    5. git cherry-pick <hash>

      What it doesCommits a specific commit change from another branch to the current branch without merging the entire branch

      When to use itto move a hotfix from the development branch to the production branch

      Examplegit cherry-pick a1b2c3d

    Offline · Reading cached copy