给定提交散列,在GitHub上查找提交 [英] Find a commit on GitHub given the commit hash

查看:99
本文介绍了给定提交散列,在GitHub上查找提交的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我被要求做一个代码审查,并且已经提交了一个提交哈希,但是我已经尝试在Git中寻找,如果我可以使用提交哈希搜索,但无法找到任何东西。



有没有一种方法可以找到更改后的代码使用提交散列?

解决方案

形式的URL https://github.com/< ; owner> /< project> / commit /< hash> 将显示在该提交中引入的更改。例如,下面是我对GitHub上的一个项目所做的最新错误修正:

https://github.com/jerith666/git-graph/commit/35e32b6a00dec02ae7d7c45c6b7106779a124685



您也可以缩短散列到任何唯一的前缀,如下所示:



https://github.com/jerith666/git-graph/commit/35e32b






我知道你只是询问了GitHub,但是为了完整性:如果你已经从命令行检出了存储库,那么你可以通过这些命令实现基本相同的事情(唯一的前缀也可以在这里工作):

  git show 35e32b6a00dec02ae7d7c45c6b7106779a124685 
git log -p -1 35e32b6a00dec02ae7d7c45c6b7106779a124685


I am fairly new to Github and have come across an amateur-ish problem.

I have been asked to do a code review and have been provided with a commit hash, however I have tried looking in Git if I can search using commit hashes but couldn't find anything.

Is there a way I can find the changed code just by using the commit hash?

解决方案

A URL of the form https://github.com/<owner>/<project>/commit/<hash> will show you the changes introduced in that commit. For example here's a recent bugfix I made to one of my projects on GitHub:

https://github.com/jerith666/git-graph/commit/35e32b6a00dec02ae7d7c45c6b7106779a124685

You can also shorten the hash to any unique prefix, like so:

https://github.com/jerith666/git-graph/commit/35e32b


I know you just asked about GitHub, but for completeness: If you have the repository checked out, from the command line, you can achieve basically the same thing with either of these commands (unique prefixes work here too):

git show 35e32b6a00dec02ae7d7c45c6b7106779a124685
git log -p -1 35e32b6a00dec02ae7d7c45c6b7106779a124685

这篇关于给定提交散列,在GitHub上查找提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆