emacs-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: git question: how do I get a specific git version into my working di


From: Eric Abrahamsen
Subject: Re: git question: how do I get a specific git version into my working directory?
Date: Sat, 18 Apr 2015 20:48:28 +0800
User-agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux)

Steinar Bang <address@hidden> writes:

>>>>>> Alan Mackenzie <address@hidden>:
>
>> Hello, Emacs.
>> A simple question (I hope):  How do I get a specific SW revision into my
>> working directory.  I want to do something like this:
>
>>    git <command> 7e09ef09a479731d01b1ca46e94ddadd73ac98e3
>
>> git checkout doesn't seem to be the thing.
>
> "git checkout 7e09ef09a479731d01b1ca46e94ddadd73ac98e3" should work.
>
> What result do you get and what were you expecting?  Do you have any
> uncommitted files it refuses to overwrite?  If so, try
>  git stash
>  git checkout 7e09ef09a479731d01b1ca46e94ddadd73ac98e3
>  git stash pop
>
> (don't stash if you have staged files, I think you have uncovered a bug
> there...)
>
>> Neither does git revert.  What is <command> here?
>
> The command is "checkout".
>
> WARNING! Dangeous work-losing command ahead!
> There is also
>  git reset --hard 7e09ef09a479731d01b1ca46e94ddadd73ac98e3
> which will overwrite anything uncommitted and set your workstate to the
> version described in 7e09ef09a479731d01b1ca46e94ddadd73ac98e3.
>
> If you just want to apply that commit, do:
>  git cherry-pick 7e09ef09a479731d01b1ca46e94ddadd73ac98e3

I think the recommended approach is to create a branch pointing at a
specific commit. So:

git checkout -b test_branch 7e09ef09

Otherwise you're in a "detached head" state, which can have odd results.
The branch method is at least a little more stable.

Eric




reply via email to

[Prev in Thread] Current Thread [Next in Thread]