Reputation: 30521
Can anyone clarify some things things for me. If I go back a previous commit using
git checkout HASH
git branch
shows (no branch)
. What does this mean?Upvotes: 2
Views: 241
Reputation: 2198
It means you have a detached HEAD ref pointing at the commit you checked out. This means any commits going ahead will not be associated with a branch and will only be accessible by commit SHA once you move HEAD off the detached tree.
No branch is created or updated. You will create a commit tree that starts at your checked out commit, however it isn't part of any branch until you tell git to make this tree part of a branch.
It is intended to do manipulations on that commit that you may not wish to make a part of any branch in your repository. This could be for throw-away work. You could always make a new branch from a previous commit should you wish to do so.
git-checkout man page provides a good explanation of these issues and would clarify your understanding of checkout being used in these various ways.
Upvotes: 1
Reputation: 1329672
git checkout -b aNewBranch
is enough to create a new branch, which will reference your current commit (which will no longer be a "detached HEAD").Upvotes: 0