Git switch command

A switch command has been added in the new version of git

Let's look at examples:

# switched to <branch>

git switch <branch>

# creates a new <branch>

git switch -c <branch>

# switched to commit 

git switch -d <commit> 

# creates and switches to branch from remote. 

# need to use if branch exists in multiple remotes 

git switch -c <branch> --track <remote>/<branch> 

# switch to a branch even if the index or working tree is different from HEAD

# this is used to throw away local changes

git switch --discard-changes <branch>

# alias for  --discard-changes

git switch -f <branch> 

# switch back to the previous branch before we switched

git switch - 

Command available on version Git 2.23.0 or higher

F1da6295 53db 49a5 8eed b3750729d42c rectangle 400 x

Backend Developer at JetRockets