i have just do like this:
git checkout HEAD@{1} 
and it says I have changed to detached head state.
How can I do the same thing without changing to detached head state?
i have just do like this:
git checkout HEAD@{1} 
and it says I have changed to detached head state.
How can I do the same thing without changing to detached head state?
 
    
    If you're wanting to move the state of the current branch back to HEAD@{1} (potentially eliminating commits), then you'd want to use git reset --hard HEAD@{1} instead of git checkout.
Note that git reset --hard is a destructive operation.
If you're wanting to switch branches, then you should pass the name of the branch to git checkout (or use git checkout - to swap to whatever branch you were previously on before the current one).
 
    
    Think about what exactly you want to end up with. If you do not check out a branch, there can only be a detached head. I am assuming you want to move your branch back to its previous state – you can do that with this command:
git reset --hard HEAD@{1}
If you just want to check out the branch you had checked out before, this is what you’re looking for:
git checkout -
 
    
    Do you want to start a new branch? Just do:
git checkout -b new-branch-name HEAD@{1}
