Junior — Middle
Can you explain the purpose of the 'git checkout' command and how it is used in Git workflows?
sobes.tech AI
Answer from AI
The git checkout command is used to switch between branches or to restore files in the working directory.
Main uses:
-
Switching branches:
git checkout branch_nameAllows you to switch to another branch to work with its contents.
-
Restoring files:
git checkout -- path/to/fileReverts local changes in the specified file, returning it to the state of the last commit.
In Git workflows, git checkout helps quickly switch between tasks, development branches, and also revert changes in files if necessary.