Switch Branches
git switch changes branches and git switch -c creates and switches. It is clearer than checkout, which also restores files.
Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
git switch -q -c work
git branch --show-current
git switch -q main
git branch --show-currentResult
work main
Exercise
Create and switch.
git switch work
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.