Tsallaka zuwa abun ciki
Justice Tech School

Detached HEAD

Checking out a commit instead of a branch gives a detached HEAD. Create a branch to keep work.

Example
echo one > a.txt && git add a.txt && git commit -qm 'first'
echo two >> a.txt && git commit -qam 'second'
git checkout -q HEAD~1
git branch --show-current | wc -c
git switch -q -c rescue
git branch --show-current

Result

0
rescue

Exercise

Keep detached work.

git switch  name

Quiz Test

What is a detached HEAD?

These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.