Advanced
Stashing Changes
git stash temporarily shelves uncommitted changes so you can switch branches with a clean working directory, then reapply them later with git stash pop. It's the fastest way to context-switch without making a throwaway commit.
git stash # save uncommitted changes
git checkout main
# ...handle something urgent...
git checkout feature/login
git stash pop # restore the stashed changes
Advanced
Rebasing vs. Merging
git merge combines two branches and preserves history exactly as it happened, including a merge commit. git rebase instead replays your branch's commits on top of another branch, producing a linear history — useful for a clean log, but it rewrites commit hashes, so avoid rebasing commits that are already shared/pushed with others.
git checkout feature/login
git rebase main # replay feature commits on top of main