git checkout does too many things (switch branches, restore files, create branches). Git 2.23+ splits it into clear commands.
Old Confusing Way:
# Switch branch git checkout main # Create and switch to new branch git checkout -b feature # Restore file git checkout -- file.txt # All same command! Confusing!
New Clear Commands:
# Switch branch git switch main # Create and switch to new branch git switch -c feature # Restore file git restore file.txt # Separate commands for separate purposes!
Additional Restore Options:
# Unstage file (keep changes) git restore --staged file.txt # Restore file from specific commit git restore --source=HEAD~2 file.txt # Restore all files git restore .
Clearer intent, less confusion!
