On Tue, 27 Oct 2015 17:47:18 -0700 (PDT)
Jorge V GM <jev...@gmail.com> wrote:

> I have this case:
> a. I develop a html file in several days with daily commit
> b. some weeks after I noticed that I lost part of the code
> c. I located a code 3 commits ago.
> then How I can fetch from the remote repository the html file as was
> 3 commit before ? (the whole file)


  $ git show HEAD~3:path/to/that/file.html >localfile.html

This command:

1) Reads a commit which is the grand-grand-parent of the HEAD commit.
2) Extracts the contents of the file located at
   "path/to/that/file.html" in that commit and prints it to the standard
3) Since you want to actually save that contents, you use the shell
   stream redirection ">" to redirect the standard output of the `git`
   program to a file "localfile.html".

To solidify this knowledge, consider now reading the manual page
of the `git show` command and the `gitrevisions(7)` manual page which
will explain what "<revision>~N" means and which other nifty forms of
referring to revisions exist.  To read those manual pages, you can
run `git help show` and `git help revisions`.

As a last note, if you want to just *overwrite* your current HTML file
with its contents as recorded in that HEAD~3 commit, you can save typing
and use

  $ git checkout HEAD~3 path/to/local/file.html

You received this message because you are subscribed to the Google Groups "Git 
for human beings" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to git-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to