unofficial mirror of emacs-devel@gnu.org 
 help / color / mirror / code / Atom feed
From: Eric Abrahamsen <eric@ericabrahamsen.net>
To: emacs-devel@gnu.org
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	[thread overview]
Message-ID: <87lhhpiov7.fsf@ericabrahamsen.net> (raw)
In-Reply-To: 86sibx7hos.fsf@dod.no

Steinar Bang <sb@dod.no> writes:

>>>>>> Alan Mackenzie <acm@muc.de>:
>
>> 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




  parent reply	other threads:[~2015-04-18 12:48 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-18 10:33 git question: how do I get a specific git version into my working directory? Alan Mackenzie
2015-04-18 10:42 ` Andreas Schwab
2015-04-18 12:18 ` Steinar Bang
2015-04-18 12:42   ` Eli Zaretskii
2015-04-18 13:16     ` Alan Mackenzie
2015-04-18 13:20       ` Dmitry Gutov
2015-04-18 13:37       ` Eli Zaretskii
2015-04-18 14:07         ` Harald Hanche-Olsen
2015-04-18 14:43           ` Eli Zaretskii
2015-04-18 17:09             ` Stefan Monnier
2015-04-18 17:37               ` Eli Zaretskii
2015-04-18 17:44                 ` Harald Hanche-Olsen
2015-04-18 12:48   ` Eric Abrahamsen [this message]
2015-04-18 13:09   ` Alan Mackenzie
2015-04-18 13:18     ` Dmitry Gutov
2015-04-18 13:57     ` Steinar Bang
2015-04-18 14:03     ` Andreas Schwab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87lhhpiov7.fsf@ericabrahamsen.net \
    --to=eric@ericabrahamsen.net \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).