aqavi_paracha
aqavi_paracha

Reputation: 1131

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

Upvotes: 2

Views: 958

Answers (3)

VonC
VonC

Reputation: 1323045

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.

Upvotes: 2

dubiousjim
dubiousjim

Reputation: 4802

cd into the git repository. Type git tag and see if the version you're looking for shows up. If it does, you're lucky. Then you can do something like this (I assume the version you're looking for shows up as v1.2.3):

git checkout v1.2.3
autoreconf # with git repos, this is often necessary before the next step
./configure
make
sudo make install

If the version didn't show up with git tag, though, then you'll need to do something like git log --oneline | more instead and look for the relevant hash id that way. If that gives you too little information, just do git log | more.

Upvotes: 2

Matti Lyra
Matti Lyra

Reputation: 13078

you can use gitk to explore the repository along with its history and the hashes for the versions, or for a simple output of the commit messages and the commit hash use git log.

Upvotes: 1

Related Questions