Re: how do i re-add a file?

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

 



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@xxxxxxxxxx> 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@xxxxxxxxxx>
>  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@xxxxxxxxxxxxxxx
>  More majordomo info at  http://vger.kernel.org/majordomo-info.html
>


-- 
James
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux