Git仓库唯一ID [英] Git repository unique id

查看:600
本文介绍了Git仓库唯一ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要确定某个提交是否属于某个特定的git存储库。

这个想法是为我需要测试的每个存储库生成一些唯一的ID。
然后我可以比较这个唯一的id与id,从测试的提交中计算出来。



例如,获取初始更改集的SHA。它可以唯一标识存储库吗?

解决方案

SHA1键是关于识别内容 blob或树),而不是仓库。

如果内容不同于回购到回购,那么它的历史没有共同的祖先,所以我不认为基于变更集的解决方案将可以工作。



也许(未测试)您可以通过 git notes

请参阅 GitHub deploy-notes ,它使用这种机制来跟踪部署情况。


I need to find out if a commit belongs to a particular git repository.

The idea is to generate some unique id for every repository I need to test. Then I can compare this unique id to the id, calculated from tested commit.

For example take an SHA of initial change set. Can it uniqely identify the repository?

解决方案

The SHA1 key is about identifying the content (of a blob, or of a tree), not about a repository.
If the content differ from repo to repo, then its history has no common ancestor, so I don't think a change-set-based solution will work.

Maybe (not tested) you could add some marker (without having to change all the SHA1) through git notes.
See for instance GitHub deploy-notes which uses this mechanism to track deployments.

这篇关于Git仓库唯一ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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