简体   繁体   中英

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

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 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 git log | more .

您可以使用gitk来探索存储库及其历史记录和版本的哈希值,或者使用提交消息和提交哈希的简单输出来使用git log

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM