Search code examples
gitrevert

how to get sha hash of previous version, git


I've downloaded an open source code from Git repository. Now I want to revert to a previous version. How can I do that? There is a command like: "git revert , but I don't know the hash of a version, say version 264 of the code

Best regards


Solution

  • git rev-list --tags --max-count=2
    

    Would also list the last two tags SHA1. The second one would be the one you need for a git checkout to work (and revert the content of the repo to the previous label)

    Once you have that SHA1, a git describe --tags xxx would translate said SHA1 into a tag label.