Create and switch branches
switch -c creates a branch from the current commit. switch - returns to the previous branch. branch -d protects branches with unmerged changes.
git branch -vv
git switch -c feature/docs
git switch main
git switch -
git branch --merged main
git branch -d feature/docs
Integrate changes and resolve conflicts
From your working branch, you can merge origin/main. If conflicts occur, edit the files, stage them and continue the merge. Use --abort if you decide to cancel it.
git fetch origin
git merge origin/main
git status
git add -- README.md
git merge --continue
git merge --abort
Apply a specific commit
cherry-pick applies a commit’s changes to the current branch. Replace abc1234 with its ID.
git show abc1234
git cherry-pick abc1234