lars111
lars111

Reputation: 1313

Git: Checkout certain commit: "detached head" state

I want to go back to a certain commit (not just one file; the whole project). I tried: git checkout 0780033 but then I got the following message:

You are in "detached head" state. You can look around...

And then I am not in actual Branch --> but in branch ((0780033...). I want to "copy" the project at this commit (0780033), to be the newest version.

Upvotes: 2

Views: 806

Answers (2)

Rafael Freire
Rafael Freire

Reputation: 41

When you checkout to a specific commit, you change to detached head state that means that you aren't in your branch anymore.

You can create a new branch from your specific commit as @Mureinik explained with:

$ git checkout -b my_new_branch

And come back to your branch with:

$ git checkout previous_branch

If you want to know more about detached state, I'd suggest you to read the following links:

Upvotes: 2

Mureinik
Mureinik

Reputation: 312219

You could check out this commit to a new branch and work from there:

$ git checkout -b my_new_branch

Upvotes: 0

Related Questions