Git get commit hash before a specific commit

git 1.7.1

git show <hash>:<file> gives me a file based on commit hash

I am trying to figure out how to put the file of the previous commit to the one with the hash.

I know that I can always use log to get all the hashes and find out what I need, but this is not a very good solution in my case, as I try to minimize the number of commands that I need to do for performance problems.

I wonder if there is an easy way.

+6
source share
1 answer

Use git show HEAD^1 . You can replace HEAD with your commit-hash

Change the account of several parents:

If you want to see all parents for a commit hash, you can use git rev-list --parents -n 1 <commithash> or use git show as @Bhaskar suggested in the comments to the question.

Other methods as well as explained here .

+7
source

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


All Articles