# Getting a file revision

11 messages from 2007-08-19 to 2007-08-21. Participants: Bahadir Balban, Junio C Hamano, J. Bruce Fields, Jerome Lovy, Miklos Vajna, Johannes Sixt, VMiklos, David Kastrup, Robin Rosenberg.
Thread: https://gitlist.dev/t/9570

## Bahadir Balban, 2007-08-19 00:42

Subject: Getting a file revision
Message-ID: <7ac1e90c0708181742w531dab4asc7c90835cc56e8a1@mail.gmail.com>
URL: https://gitlist.dev/e/7ac1e90c0708181742w531dab4asc7c90835cc56e8a1%40mail.gmail.com

```
Hi,

This might sound like a novice question but anyway: I sometimes have a
need to quickly recover an old revision of a file just to check
something or copy some code from it. I would imagine having a command
like:

git-getrev <filename> <commit> or something, and the file would appear
in its path, or the git root directory as <filename>.<commit>

Is there an existing way to achieve a similar result? I can certainly
checkout a branch, revert to that commit I want, copy the file, and
come back to HEAD, but its not as quick.

Thanks,
Bahadir

```

## Junio C Hamano, 2007-08-19 00:52

Subject: Re: Getting a file revision
Message-ID: <7vir7ccpmj.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vir7ccpmj.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <7ac1e90c0708181742w531dab4asc7c90835cc56e8a1@mail.gmail.com>

```
"Bahadir Balban" <bahadir.balban@gmail.com> writes:

> This might sound like a novice question but anyway: I sometimes have a
> need to quickly recover an old revision of a file just to check
> something or copy some code from it.

$ git show -p $commit:$path >$path.old-version

```

## J. Bruce Fields, 2007-08-19 00:52

Subject: Re: Getting a file revision
Message-ID: <20070819005229.GA12095@fieldses.org>
URL: https://gitlist.dev/e/20070819005229.GA12095%40fieldses.org
In-Reply-To: <7ac1e90c0708181742w531dab4asc7c90835cc56e8a1@mail.gmail.com>

```
On Sun, Aug 19, 2007 at 01:42:30AM +0100, Bahadir Balban wrote:
> This might sound like a novice question but anyway: I sometimes have a
> need to quickly recover an old revision of a file just to check
> something or copy some code from it. I would imagine having a command
> like:
> 
> git-getrev <filename> <commit> or something, and the file would appear
> in its path, or the git root directory as <filename>.<commit>
> 
> Is there an existing way to achieve a similar result? I can certainly
> checkout a branch, revert to that commit I want, copy the file, and
> come back to HEAD, but its not as quick.

Easiest is probably to use git-show together with the
<commit>:<filename> syntax, so e.g.:

	git show v1.4:src/main.c
	git show 74ace5df:Makefile >Makefile.tmp

--b.

```

## Jerome Lovy, 2007-08-20 11:38

Subject: Re: Getting a file revision
Message-ID: <46C97D26.9090102@brefemail.com>
URL: https://gitlist.dev/e/46C97D26.9090102%40brefemail.com
In-Reply-To: <7vir7ccpmj.fsf@gitster.siamese.dyndns.org>

```
Hi,

Junio C Hamano wrote:
> "Bahadir Balban" <bahadir.balban@gmail.com> writes:
> 
>> This might sound like a novice question but anyway: I sometimes have a
>> need to quickly recover an old revision of a file just to check
>> something or copy some code from it.
> 
> $ git show -p $commit:$path >$path.old-version
Is "-p" a short version of "--pretty" ?

(I do not see it documented in the man-page and assume it is not the 
"-p" applicable to git-diff-tree, is it ?)

Thanks,
Jérôme

```

## Miklos Vajna, 2007-08-21 12:49

Subject: [PATCH] Document the -p option for git-show.
Message-ID: <20070821124949.GH768@genesis.frugalware.org>
URL: https://gitlist.dev/e/20070821124949.GH768%40genesis.frugalware.org
In-Reply-To: <46C97D26.9090102@brefemail.com>

```
Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
---
 Documentation/git-show.txt |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt
index a42e121..2409389 100644
--- a/Documentation/git-show.txt
+++ b/Documentation/git-show.txt
@@ -33,6 +33,10 @@ This manual page describes only the most frequently used options.
 
 OPTIONS
 -------
+
+-p::
+	For commits, show the change the commit introduces in a patch form.
+
 <object>::
 	The name of the object to show.
 	For a more complete list of ways to spell object names, see
-- 
1.5.2.2

```

## Johannes Sixt, 2007-08-21 13:09

Subject: Re: [PATCH] Document the -p option for git-show.
Message-ID: <46CAE41C.4614FDF4@eudaptics.com>
URL: https://gitlist.dev/e/46CAE41C.4614FDF4%40eudaptics.com
In-Reply-To: <20070821124949.GH768@genesis.frugalware.org>

```
Miklos Vajna wrote:
> +-p::
> +       For commits, show the change the commit introduces in a patch form.

This is already documented by referencing git-diff-tree a few lines
above:

	The command takes options applicable to the git-diff-tree[1]
	command to control how the changes the commit introduces are
	shown.

The man page of git-diff-tree talks about -p, and a lot more options.

Side note: -p is the default for git-show (of commits). Nevertheless, it
makes sense to specify it in combination with other options:

	git show -p --stat

will show both the patch and the statistics.

-- Hannes

```

## VMiklos, 2007-08-21 14:29

Subject: Re: [PATCH] Document the -p option for git-show.
Message-ID: <20070821142915.GI768@genesis.frugalware.org>
URL: https://gitlist.dev/e/20070821142915.GI768%40genesis.frugalware.org
In-Reply-To: <46CAE41C.4614FDF4@eudaptics.com>

```
Hello,

Na Tue, Aug 21, 2007 at 03:09:48PM +0200, Johannes Sixt <J.Sixt@eudaptics.com> pisal(a):
> This is already documented by referencing git-diff-tree a few lines
> above:
> 
> 	The command takes options applicable to the git-diff-tree[1]
> 	command to control how the changes the commit introduces are
> 	shown.
> (..)
> Side note: -p is the default for git-show (of commits). Nevertheless, it
> makes sense to specify it in combination with other options:
> 
> 	git show -p --stat
> 
> will show both the patch and the statistics.

Hm, but -p is used by default for git show, right? And this is not
documented anywhere IMHO. (Maybe other options are used by default,
too?)

- VMiklos

```

## David Kastrup, 2007-08-21 15:02

Subject: Re: [PATCH] Document the -p option for git-show.
Message-ID: <867inpexsm.fsf@lola.quinscape.zz>
URL: https://gitlist.dev/e/867inpexsm.fsf%40lola.quinscape.zz
In-Reply-To: <46CAE41C.4614FDF4@eudaptics.com>

```
Johannes Sixt <J.Sixt@eudaptics.com> writes:

> Miklos Vajna wrote:
>> +-p::
>> +       For commits, show the change the commit introduces in a patch form.
>
> This is already documented by referencing git-diff-tree a few lines
> above:
>
> 	The command takes options applicable to the git-diff-tree[1]
> 	command to control how the changes the commit introduces are
> 	shown.
>
> The man page of git-diff-tree talks about -p, and a lot more
> options.

I am not really convinced this is a good idea: at the current point of
time, man-pages are not pulled into they user manual or any other
complete reference tome.  So they are basically standalone.  Even if
they weren't, I think it does not make all too much sense for a
porcelain command to point to the documentation of a plumbing command
for much of its functionality.

-- 
David Kastrup

```

## Robin Rosenberg, 2007-08-21 17:01

Subject: Re: [PATCH] Document the -p option for git-show.
Message-ID: <200708211901.55687.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200708211901.55687.robin.rosenberg.lists%40dewire.com
In-Reply-To: <20070821124949.GH768@genesis.frugalware.org>

```
tisdag 21 augusti 2007 skrev Miklos Vajna:
> Signed-off-by: Miklos Vajna <vmiklos@frugalware.org>
> ---
>  Documentation/git-show.txt |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt
> index a42e121..2409389 100644
> --- a/Documentation/git-show.txt
> +++ b/Documentation/git-show.txt
> @@ -33,6 +33,10 @@ This manual page describes only the most frequently used options.
>  
>  OPTIONS
>  -------
> +
> +-p::
> +	For commits, show the change the commit introduces in a patch form.
> +
>  <object>::
>  	The name of the object to show.
>  	For a more complete list of ways to spell object names, see
How about this instead:

-- robin

Include diff options into git-show command manual

--
 Documentation/git-show.txt |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Documentation/git-show.txt b/Documentation/git-show.txt
index a42e121..d4708e0 100644
--- a/Documentation/git-show.txt
+++ b/Documentation/git-show.txt
@@ -41,6 +41,9 @@ OPTIONS
 include::pretty-options.txt[]
 
 
+include::diff-options.txt[]
+
+
 include::pretty-formats.txt[]
 
 

```

## Junio C Hamano, 2007-08-21 17:33

Subject: Re: [PATCH] Document the -p option for git-show.
Message-ID: <7v1wdwpzbd.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7v1wdwpzbd.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <200708211901.55687.robin.rosenberg.lists@dewire.com>

```
Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:

> How about this instead:
>
> -- robin
>
> Include diff options into git-show command manual

I think that is probably a good idea but I wonder if placing
diff-options in between of pretty-options and pretty-formats is
a good idea.

```

## Robin Rosenberg, 2007-08-21 18:50

Subject: Re: [PATCH] Document the -p option for git-show.
Message-ID: <200708212050.37227.robin.rosenberg.lists@dewire.com>
URL: https://gitlist.dev/e/200708212050.37227.robin.rosenberg.lists%40dewire.com
In-Reply-To: <7v1wdwpzbd.fsf@gitster.siamese.dyndns.org>

```
tisdag 21 augusti 2007 skrev Junio C Hamano:
> Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:
> 
> > How about this instead:
> >
> > -- robin
> >
> > Include diff options into git-show command manual
> 
> I think that is probably a good idea but I wonder if placing
> diff-options in between of pretty-options and pretty-formats is
> a good idea.

Since pretty-formats is a new section in the man page it works out fine. I
actually ran make and man to verify this patch.

-- robin

```
