From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Eric Abrahamsen Newsgroups: gmane.emacs.devel 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 Message-ID: <87lhhpiov7.fsf@ericabrahamsen.net> References: <20150418103301.GB4182@acm.fritz.box> <86sibx7hos.fsf@dod.no> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1429361344 17355 80.91.229.3 (18 Apr 2015 12:49:04 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 18 Apr 2015 12:49:04 +0000 (UTC) To: emacs-devel@gnu.org Original-X-From: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Sat Apr 18 14:48:56 2015 Return-path: Envelope-to: ged-emacs-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1YjSB5-0006Xx-1r for ged-emacs-devel@m.gmane.org; Sat, 18 Apr 2015 14:48:55 +0200 Original-Received: from localhost ([::1]:45605 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjSB4-0004Ur-DY for ged-emacs-devel@m.gmane.org; Sat, 18 Apr 2015 08:48:54 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58235) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjSAq-0004Uk-U9 for emacs-devel@gnu.org; Sat, 18 Apr 2015 08:48:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YjSAm-0003aj-TU for emacs-devel@gnu.org; Sat, 18 Apr 2015 08:48:40 -0400 Original-Received: from plane.gmane.org ([80.91.229.3]:32816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YjSAm-0003ae-MZ for emacs-devel@gnu.org; Sat, 18 Apr 2015 08:48:36 -0400 Original-Received: from list by plane.gmane.org with local (Exim 4.69) (envelope-from ) id 1YjSAk-0006L9-LQ for emacs-devel@gnu.org; Sat, 18 Apr 2015 14:48:34 +0200 Original-Received: from 222.129.224.131 ([222.129.224.131]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 18 Apr 2015 14:48:34 +0200 Original-Received: from eric by 222.129.224.131 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Sat, 18 Apr 2015 14:48:34 +0200 X-Injected-Via-Gmane: http://gmane.org/ Original-Lines: 45 Original-X-Complaints-To: usenet@ger.gmane.org X-Gmane-NNTP-Posting-Host: 222.129.224.131 User-Agent: Gnus/5.130012 (Ma Gnus v0.12) Emacs/25.0.50 (gnu/linux) Cancel-Lock: sha1:R5bMWxshCKffWIT1pTWnTU5kcBA= X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 80.91.229.3 X-BeenThere: emacs-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Emacs development discussions." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Original-Sender: emacs-devel-bounces+ged-emacs-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.devel:185574 Archived-At: Steinar Bang writes: >>>>>> Alan Mackenzie : > >> 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 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 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