Wed, 15 Sep 2010 15:09:30 +0200, Gael Varoquaux wrote:
[clip]
> Reading the above, it seemed to me that I could always revert my
> previous action (unless it impacted non-tracked files) using:
> 
>     git checkout h...@{0}
> 
> I just tried it on a copy of a repo I had, and I get "You are in a
> 'detached HEAD'". From what I understand from the message (and Google) I
> simply need to do a "git checkout -b new_branch" to be in a state where
> I can work. However, it seem to me that when I switch back the the
> master branch, and merge my new_branch, I haven't "undone" the action I
> was trying to undo.

Suppose you just messed up `somebranch`. First, check its reflog:

    $ git reflog show somebranch

and pick a state that seems good, usually somebra...@{1} if you didn't do 
new commits etc. on the branch yet:

    $ git checkout somebra...@{1}
    ... check now that this is the state you'd like somebranch to have...
    $ git branch -f somebranch somebra...@{1}

which moves `somebranch` to its previous state.

Note that 

    $ git reflog

does *NOT* show the reflog of the current branch -- it shows the reflog 
of HEAD, which can in some cases be confusing. The point is that HEAD is 
a meta-branch that corresponds to the current checkout, and so changes 
every time you use "git checkout".

-- 
Pauli Virtanen

_______________________________________________
NumPy-Discussion mailing list
NumPy-Discussion@scipy.org
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to