Streamlining Git Workflows: Using git switch and git restore Over git checkout

Stefanie Lai
6 min readSep 2, 2024

Enhancing Clarity and Efficiency in Branch Management and File Restoration with Modern Git Commands

from Unsplash

In code management, the de facto standard is Git, in which git checkout is now a prevailing command for switching branches, checking out specific commits, and creating new branches.

However, git switch and git restore introduced in Git 2.23 can to some extent replace the role of git checkout in some scenarios, simplifying and clarifying operations like branches switching and files rolling back. In this article, we will deepen into git checkout, git switch, and git restore , and explore more on using them effectively in the workstream mode.

Command in Different Scenarios

git checkout

from https://git-scm.com/docs/git-checkout

It is a multi-functional command that commonly used in scenarios to

  • Switch to a different branch, e.g. git checkout <branch_name>.
  • Create and switch to a new branch, e.g. git checkout -b <new-branch>.
  • Create and switch to a remote branch, e.g. git checkout -b

--

--