Git: how to check the source version of a file in a git repository

I am wondering if there is a better way to check the original version of the file than the obvious way:

git log --reverse [path/to/file]

copy the first sha1 file

git checkout [found sha1] [path/to/file]

We have HEAD for the very latest, and the suffix ^ to go back (or more), but I have not seen any good way to go back to the beginning.

+3
source share
1 answer

Well, you should use command substitution:

git checkout $(git log --follow --pretty=%H path/to/file | tail -n 1) path/to/file

but nothing will be fundamentally simpler. Git tracks content, not files, so it doesn't have a “version one of file A” entry - going through the history to find it.

--reverse, - , , , .

-, ( , ), .

+4

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


All Articles