Published on:
Last updated: November 3rd. 2021
Do you ever come back to an old project and find out that you've left it behind (partially) broken? I sure do. So you start to check out previous commits to find if there was a moment where most of your code was still working properly. But then, git
gives you a message like this:
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new branch name>
If you're like me, you would probably go like: sure, whatever I'll deal with that later.
It's as easy as:
git push origin master