DELAPARRA
Index
Color
NL
Category: Git commands

git switch

Explained by Updated

What is git switch?

git switch: Switch to a different branch (modern replacement for git checkout). git switch changes to another branch. git switch main goes to main, git switch -c feature/export creates a new branch and switches to it, and git switch - jumps back to the previous branch. It was added in Git 2.23 to take over the branch part of the older git checkout. Because it only switches branches, it cannot accidentally overwrite files the way a mistyped checkout could.

Definition source Coders Lingo, CC BY 4.0

Frequently asked questions about git switch

What should you keep in mind with git switch?

If you have uncommitted changes that would conflict with the other branch, Git refuses to switch and tells you why. Commit or stash them first. Most modern tutorials and tools use switch and restore, so they are worth learning if you still type checkout out of habit.

At a glance

CategoryGit commands
Explained by
Updated

More Git commands terms

All terms starting with G

Skills

Download all skills (zip)

Manuals

Related services

Need any help?

Stuck on one of these in your own project? Tell me what you are working on and I will tell you how I would approach it.