Courses / GitHub
5. Switching branches (git switch / git checkout)
Changing the working branch using git switch or git checkout and understanding detached HEAD states.
Git / Bash
Switching branches (git switch / git checkout)
Changing which branch your working directory is on so you can work on a different line of development.
"I need to work on a new feature without losing the code I'm editing on another branch."
Switching branches updates HEAD to point at a branch name and updates working files to match that branch; using a commit hash can put you in a detached HEAD state where HEAD points directly at a commit.
"I need to work on a new feature without losing the code I'm editing on another branch."
Switching branches updates HEAD to point at a branch name and updates working files to match that branch; using a commit hash can put you in a detached HEAD state where HEAD points directly at a commit.