Branches
A branch is an independent line of development — great for working on a feature without touching the stable code.
Create and switch branches
git branch feature-login # Create
git switch feature-login # Switch (modern)
git checkout feature-login # Switch (classic)
git switch -c feature-login # Create + switch in one step
List branches
git branch # Local branches
git branch -a # All, including remote
Merge a branch into the current one
git switch main
git merge feature-login
Merge conflicts
When two branches change the same lines, Git can't decide automatically:
<<<<<<< HEAD
your version
=======
incoming version
>>>>>>> feature-login
Edit the file to keep what you want, remove the markers, then:
git add file.txt
git commit
Delete a branch
git branch -d feature-login # Safe delete (merged only)
git branch -D feature-login # Force delete