Skip to content
Justice Tech School

Switching Branches

git switch moves between branches and updates your files.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
git switch -q -c dev
echo dev > d.txt && git add d.txt && git commit -qm 'dev work'
git switch -q main
ls
git switch -q dev
ls

Result

a.txt
a.txt
d.txt

Exercise

Go to main.

git switch 

Quiz Test

What happens to files on switch?

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