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.

  • How to install and use gerrit with eclipse?
  • Merge user-names in Git repository commits?
  • Remove file called --a from git
  • gradle - getWorkingBranch error on gradle-git
  • What is the best way to keep javascript libraries up-to-date in rails?
  • Git: Unable to understand why branch (topic) commits/merges are happening on the master branch
  • Git filtering after renaming the folder
  • Is there a way to include a particular version of a git submodule in a project tag?
  • Is it possible to remote count object and size of git repository?
  • Why does git commit after a merge by default?
  • Why Git doesn't ignore my specified file?
  • Rebasing remote branches in Git
  • 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>
    

    e.g.

    git checkout master~2 Makefile
    

    Reference: git checkout man page.

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