In git if you checkout a commit directly you get a big fat warning starting with:
\"You are in \'detached HEAD\' state. You can look around ...\"
Shamelessly copying mjs's comment to post it as an answer on its own:
git -c advice.detachedHead=false checkout
The -c advice.detachedHead=false
parameter will allow you to suppress the warning without having to change the global config. It will only apply to the executed command. Here's the list of all advises that can be suppressed.