git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Simple problem
@ 2008-04-28 16:31 Kenneth P. Turvey
  2008-04-28 16:35 ` Bill Lear
  2008-04-28 17:47 ` Alex Riesen
  0 siblings, 2 replies; 5+ messages in thread
From: Kenneth P. Turvey @ 2008-04-28 16:31 UTC (permalink / raw)
  To: git

I ran into an issue earlier today that I didn't know how to easily solve 
in git.  I'm sure it is easy to handle, but I wasn't sure how.  

I removed a file and then realized I'd hit the wrong one.  So all I 
wanted to do was to get the file back the way it was in the last commit.  

Basically I wanted something similar to:

svn update myfile

in subversion.  

I got it back by using a diff and just deleting all the minus signs at 
the beginning of the lines, but I'm sure this isn't the way to handle 
this.  Strangely this simple case wasn't covered by any of the tutorials 
I looked at. 

Thanks.

-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Simple problem
  2008-04-28 16:31 Simple problem Kenneth P. Turvey
@ 2008-04-28 16:35 ` Bill Lear
  2008-04-28 16:49   ` Björn Steinbrink
  2008-04-28 17:47 ` Alex Riesen
  1 sibling, 1 reply; 5+ messages in thread
From: Bill Lear @ 2008-04-28 16:35 UTC (permalink / raw)
  To: Kenneth P. Turvey; +Cc: git

On Monday, April 28, 2008 at 16:31:05 (+0000) Kenneth P. Turvey writes:
>I ran into an issue earlier today that I didn't know how to easily solve 
>in git.  I'm sure it is easy to handle, but I wasn't sure how.  
>
>I removed a file and then realized I'd hit the wrong one.  So all I 
>wanted to do was to get the file back the way it was in the last commit.  
>
>Basically I wanted something similar to:
>
>svn update myfile
>
>in subversion.  
>
>I got it back by using a diff and just deleting all the minus signs at 
>the beginning of the lines, but I'm sure this isn't the way to handle 
>this.  Strangely this simple case wasn't covered by any of the tutorials 
>I looked at. 

% rm file
[oops]
% git checkout file


Bill

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Simple problem
  2008-04-28 16:35 ` Bill Lear
@ 2008-04-28 16:49   ` Björn Steinbrink
  2008-04-28 18:58     ` Kenneth P. Turvey
  0 siblings, 1 reply; 5+ messages in thread
From: Björn Steinbrink @ 2008-04-28 16:49 UTC (permalink / raw)
  To: Bill Lear; +Cc: Kenneth P. Turvey, git

On 2008.04.28 11:35:55 -0500, Bill Lear wrote:
> On Monday, April 28, 2008 at 16:31:05 (+0000) Kenneth P. Turvey writes:
> >I ran into an issue earlier today that I didn't know how to easily solve 
> >in git.  I'm sure it is easy to handle, but I wasn't sure how.  
> >
> >I removed a file and then realized I'd hit the wrong one.  So all I 
> >wanted to do was to get the file back the way it was in the last commit.  
> >
> >Basically I wanted something similar to:
> >
> >svn update myfile
> >
> >in subversion.  
> >
> >I got it back by using a diff and just deleting all the minus signs at 
> >the beginning of the lines, but I'm sure this isn't the way to handle 
> >this.  Strangely this simple case wasn't covered by any of the tutorials 
> >I looked at. 
> 
> % rm file
> [oops]
> % git checkout file

That restores the version from the index, so it will fail if you did
"git rm file". To get the file from HEAD use "git checkout HEAD --
file".

Björn

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Simple problem
  2008-04-28 16:31 Simple problem Kenneth P. Turvey
  2008-04-28 16:35 ` Bill Lear
@ 2008-04-28 17:47 ` Alex Riesen
  1 sibling, 0 replies; 5+ messages in thread
From: Alex Riesen @ 2008-04-28 17:47 UTC (permalink / raw)
  To: Kenneth P. Turvey; +Cc: git

Kenneth P. Turvey, Mon, Apr 28, 2008 18:31:05 +0200:
> I ran into an issue earlier today that I didn't know how to easily solve 
> in git.  I'm sure it is easy to handle, but I wasn't sure how.  
> 
> I removed a file and then realized I'd hit the wrong one.  So all I 
> wanted to do was to get the file back the way it was in the last commit.  
> 
> Basically I wanted something similar to:
> 
> svn update myfile
> 

git checkout HEAD filename

but mostly just "git checkout filename"

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Simple problem
  2008-04-28 16:49   ` Björn Steinbrink
@ 2008-04-28 18:58     ` Kenneth P. Turvey
  0 siblings, 0 replies; 5+ messages in thread
From: Kenneth P. Turvey @ 2008-04-28 18:58 UTC (permalink / raw)
  To: git

On Mon, 28 Apr 2008 18:49:45 +0200, Björn Steinbrink wrote:

[Snip]
> That restores the version from the index, so it will fail if you did
> "git rm file". To get the file from HEAD use "git checkout HEAD --
> file".

Thanks.  I tested this and it works as advertised.  I took a look at the 
man page and I understand what the -- is for too.  

I had actually tried:

git checkout myfile.java

and this didn't work.



-- 
Kenneth P. Turvey <kt-usenet@squeakydolphin.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-04-28 19:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-04-28 16:31 Simple problem Kenneth P. Turvey
2008-04-28 16:35 ` Bill Lear
2008-04-28 16:49   ` Björn Steinbrink
2008-04-28 18:58     ` Kenneth P. Turvey
2008-04-28 17:47 ` Alex Riesen

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 NNTP newsgroup(s).