Git for Windows: get older verisons of file?

I am using the great Git for Windows and I want to get old versions of a file. I mean that I want to get the entire file and not just view the code in a preview.

  • Emacs: why shell-command “git log” works, but “git shortlog” doesn't?
  • how to give a git repo a name?
  • git format-patch without committing
  • Can a Git Repository Branch be a sub folder in some other Git Repository?
  • Get the modified files
  • Why can't Heroku find my autoload.php file?
  • Git workflow and rebase vs merge questions
  • Which open-source git hosting software should I install on my company's intranet?
  • Can I fork another persons repo twice into my own account?
  • Why do the changes introduced by a commit not show up in my working tree?
  • How do I force a subtree push to overwrite remote changes?
  • How does git store duplicate files?
  • 2 Solutions collect form web for “Git for Windows: get older verisons of file?”

    The easiest way to do that is to just checkout a revision by hash of the file that you want, or the change and go back one.

    Use gitk to find the hash of the commit that you are interested in.

    You can then use git checkout hashhere. This will set your whole repository back to that hash.

    If all you want is a specific file, use git checkout hash filepath.

    For example:

    git checkout 4fda14eefe0388e836aac8feaca68ab18bfad6b1 path/to/file.c

    If all you want to do is see a file and save it off to somewhere else, git show is capable of doing that, git show hash:filepath and pipe it out to somewhere you want to save it:

    git show 4fda14eefe0388e836aac8feaca68ab18bfad6b1:path/to/file.c > savetohere.txt

    You can also use tree-ish to specify the number of revisions to go back, as well:

    git show master~2:path/to/file.c > savetohere.txt

    Which basically says, “2 revisions ago on the master branch, show the path/to/file.c file and pipe the results to savetohere.txt.”

    git checkout <tree-ish> <path>


    git checkout master~2 Makefile

    Reference: git checkout man page.

    Git Baby is a git and github fan, let's start git clone.