git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* how do i re-add a file?
@ 2008-04-01 11:10 Ittay Dror
  2008-04-01 11:41 ` James Sadler
  2008-04-01 11:41 ` Miklos Vajna
  0 siblings, 2 replies; 4+ messages in thread
From: Ittay Dror @ 2008-04-01 11:10 UTC (permalink / raw)
  To: git

I did git-rm on a file and committed. Made some changes to my sources 
and committed. Now I want the file back. How can I do that? Related to 
that, how do I revert my files to some past commit state so that the 
commits in between are kept in the history?

Thank you,
Ittay

-- 
Ittay Dror <ittayd@tikalk.com>
Tikal <http://www.tikalk.com>
Tikal Project <http://tikal.sourceforge.net>

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

* how do i re-add a file?
@ 2008-04-01 11:14 Ittay Dror
  0 siblings, 0 replies; 4+ messages in thread
From: Ittay Dror @ 2008-04-01 11:14 UTC (permalink / raw)
  To: git

I did git-rm on a file and committed. Made some changes to my sources
and committed. Now I want the file back. How can I do that? Related to
that, how do I revert my files to some past commit state so that the
commits in between are kept in the history?

Thank you,
Ittay

-- 
Ittay Dror <ittayd@tikalk.com>
Tikal <http://www.tikalk.com>
Tikal Project <http://tikal.sourceforge.net>

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

* Re: how do i re-add a file?
  2008-04-01 11:10 how do i re-add a file? Ittay Dror
@ 2008-04-01 11:41 ` James Sadler
  2008-04-01 11:41 ` Miklos Vajna
  1 sibling, 0 replies; 4+ messages in thread
From: James Sadler @ 2008-04-01 11:41 UTC (permalink / raw)
  To: Ittay Dror; +Cc: git

There are at least a couple of ways to do this.

git show <revision>:<file_name>

e.g. git show HEAD^:builtin-log.c

That will output the content to the console of the file
'builtin-log.c' at the parent revision of the current commit.   You
can redirect it to a file if you want.

git checkout <rev> <file_name>

e.g. git checkout HEAD^ builtin-log.c

Works the same as above, except the file will be written to your
working tree without you having to redirect the output to a file.

Take a look at the help for 'checkout' and 'show'. (e.g. git checkout --help )

In the above examples, 'HEAD^' is just a shortcut for specifying a
revision without entering the entire SHA1 of the commit.  See
http://www.kernel.org/pub/software/scm/git/docs/git-rev-parse.html for
more information on the various ways you can specify revisions.

Another way to look at file content at a particular revision is via
the 'gitk' GUI tool that comes with git.  Fire it up by entering
'gitk' at the command line while inside your repo.  In the pane on the
left, select the revision that you are interested in.  On the
bottom-right pane, select the radio button labeled 'tree' and navigate
through that to find you file.  When you select it, the content of the
file will be displayed on the bottom-left pane.

-- 

James.

On 01/04/2008, Ittay Dror <ittayd@tikalk.com> wrote:
> I did git-rm on a file and committed. Made some changes to my sources
>  and committed. Now I want the file back. How can I do that? Related to
>  that, how do I revert my files to some past commit state so that the
>  commits in between are kept in the history?
>
>  Thank you,
>  Ittay
>
>  --
>  Ittay Dror <ittayd@tikalk.com>
>  Tikal <http://www.tikalk.com>
>  Tikal Project <http://tikal.sourceforge.net>
>
>
>  --
>  To unsubscribe from this list: send the line "unsubscribe git" in
>  the body of a message to majordomo@vger.kernel.org
>  More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


-- 
James

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

* Re: how do i re-add a file?
  2008-04-01 11:10 how do i re-add a file? Ittay Dror
  2008-04-01 11:41 ` James Sadler
@ 2008-04-01 11:41 ` Miklos Vajna
  1 sibling, 0 replies; 4+ messages in thread
From: Miklos Vajna @ 2008-04-01 11:41 UTC (permalink / raw)
  To: Ittay Dror; +Cc: git

[-- Attachment #1: Type: text/plain, Size: 388 bytes --]

On Tue, Apr 01, 2008 at 02:10:12PM +0300, Ittay Dror <ittayd@tikalk.com> wrote:
> I did git-rm on a file and committed. Made some changes to my sources and 
> committed. Now I want the file back. How can I do that? Related to that, 
> how do I revert my files to some past commit state so that the commits in 
> between are kept in the history?

git checkout HEAD^ -- path/to/file

[-- Attachment #2: Type: application/pgp-signature, Size: 197 bytes --]

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

end of thread, other threads:[~2008-04-01 11:42 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-01 11:10 how do i re-add a file? Ittay Dror
2008-04-01 11:41 ` James Sadler
2008-04-01 11:41 ` Miklos Vajna
  -- strict thread matches above, loose matches on Subject: below --
2008-04-01 11:14 Ittay Dror

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.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).