Skip to content
Justice Tech School

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-current

Result

work
main

Exercise

Create and switch.

git switch  work

Quiz Test

Which command shows the current branch?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.