0
0
Gitdevops~5 mins

Switching branches with git switch - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What does the command git switch <branch-name> do?
It changes your current working branch to the specified branch named <branch-name>.
Click to reveal answer
beginner
How do you create and switch to a new branch named feature using git switch?
Use git switch -c feature. The -c flag creates the new branch and switches to it immediately.
Click to reveal answer
beginner
What happens if you try git switch to a branch that does not exist without the -c option?
Git will show an error saying the branch does not exist and will not switch branches.
Click to reveal answer
intermediate
Why might you prefer git switch over git checkout for switching branches?
git switch is simpler and only focuses on switching branches, making it easier and less error-prone for beginners.
Click to reveal answer
intermediate
What command would you use to switch back to the previous branch you were on?
Use git switch - to quickly go back to the last branch you had checked out.
Click to reveal answer
Which command switches to an existing branch named dev?
Agit switch -c dev
Bgit switch new dev
Cgit switch --create dev
Dgit switch dev
How do you create and switch to a new branch called feature1?
Agit switch feature1
Bgit switch -c feature1
Cgit switch --new feature1
Dgit switch -n feature1
What will happen if you run git switch unknown-branch and the branch does not exist?
AGit shows an error and does not switch
BGit switches to the default branch
CGit creates the branch and switches to it
DGit deletes the current branch
Which command switches back to the previous branch you were on?
Agit switch -
Bgit switch last
Cgit switch back
Dgit switch previous
Why is git switch recommended over git checkout for switching branches?
AIt deletes old branches automatically
BIt is faster to type
CIt only switches branches and avoids confusion
DIt merges branches automatically
Explain how to switch to an existing branch and how to create and switch to a new branch using git switch.
Think about the difference between switching and creating branches.
You got /2 concepts.
    Describe what happens if you try to switch to a branch that does not exist without creating it.
    Consider what git expects when switching branches.
    You got /3 concepts.