1. Rebasing and Cherry-Picking
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
Example
git rebase origin/maingit rebase -i HEAD~3What 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
Example
git rebase -i HEAD~3git rebase --continueWhat 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
Example
git rebase --continuegit rebase --abortWhat 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
Example
git rebase --abortgit 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
Example
git cherry-pick a1b2c3d