git checkout
git checkout switches between branches or restores files to an earlier state. It moves HEAD to a different branch or commit so your working directory reflects that version.
Git & DevOps
Historically git checkout did many jobs at once, which confused beginners. Newer Git versions split it into git switch (for changing branches) and git restore (for discarding changes), but checkout still works for both.
Switching branches updates the files in your working directory to match the branch you moved to.
Syntax
git checkout <branch>Examples
Bash
git checkout mainOutput:
Switched to branch 'main'
Your branch is up to date with 'origin/main'.