git detached head: how I restore texts (sometimes)

abstract

1. enter detached HEAD

gc ./.git/HEAD
ref: refs/heads/master
git checkout <sha>

2. rules

3. usecase

git log --pretty=format:\"%C(auto)%h%d%Creset %C(cyan)(%ci)%Creset %C(green)%cn <%ce>%Creset %s\" --name-status --date=short --all --full-history -- foo.txt
git checkout <sha>

4. sources

--

--

Infrastructure Support Engineer/Technical Writer (snowplow.io) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Pavol Kutaj

Infrastructure Support Engineer/Technical Writer (snowplow.io) with a passion for Python/writing documentation. More about me: https://pavol.kutaj.com