What are checkout
s in git?
I know once you do checkout
to a particular branch, the HEAD
points to that branch. But what does
"To check out" means that you take any given commit from the repository and re-create the state of the associated file and directory tree in the working directory.
When you check out a commit that is not a branch head (e.g. git checkout HEAD~2
), you are on a so-called detached head. You can create commits here, but once you switch to a different branch, those commits will not be recoverable by a branch name and might even get removed by the garbage collector after some time.