Hands-on task
Rescue a commit from detached HEAD
In /root/repo someone did a git checkout onto an old commit (the repository is currently in a "detached HEAD" state), did some work there in a new commit with an important file rescue.txt (contents IMPORTANT) — and this commit isn't attached to any branch: switch to main and it will be lost. Without losing it, save the current commit into a new branch named rescue so that rescue.txt survives.
- detached HEAD
- git branch
- git switch
- git reflog
- commit references