Git for Windows: get old file versions?

I am using Big Git for Windows and I want to get old versions of the file. I mean, I want to get the whole file, and not just view the code in the preview.

+3
source share
2 answers

The easiest way to do this is to simply check the version using the hash of the file you want, or change and go back.

Use gitkto find the commit hash that interests you.

Then you can use git checkout hashhere. This will return your entire repository to this hash.

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

For instance:

git checkout 4fda14eefe0388e836aac8feaca68ab18bfad6b1 path/to/file.c

, , - , git show , git show hash:filepath , :

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

tree-ish, :

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

: "2 , path/to/file.c savetohere.txt".

+5
git checkout <tree-ish> <path>

.

git checkout master~2 Makefile

: git .

+2

Source: https://habr.com/ru/post/1782530/


All Articles