如何找到Github文件的SHA Blob [英] How to find a Github file 's SHA blob

查看:219
本文介绍了如何找到Github文件的SHA Blob的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用此API更新存储库中的文件,这要求我对要更新的文件具有有效的SHA blob:

I'm using this API to update a file on my repo, it requires me to have a valid SHA blob for a file that I want to update:

http://developer.github.com/v3/repos/contents/

如何找到特定文件的SHA Blob?在我的测试帐户的testrepo中,test.txt文件的SHA blob是什么?

How do I find the SHA blob for the specific file? Supposed in my testrepo in the test account here, what is the SHA blob for the test.txt file?

https://github.com/testacc01/testrepo01

非常感谢您!

推荐答案

用于更新文件的文档指定您需要为要替换的文件提供SHA.最简单的方法就是查询github.例如:

The docs for updating a file specify that you will need to provide the SHA for the file you will be replacing. The easiest way would be to query github for that, too. For example:

> curl https://api.github.com/repos/testacc01/testrepo01/contents/test.txt
{
  "name": "test.txt",
  "path": "test.txt",
  "sha": "4f8a0fd8ab3537b85a64dcffa1487f4196164d78",
  "size": 13,
 …

因此,您可以在JSON响应的"sha"字段中看到SHA.在制定使用新版本更新文件的请求时,请使用该文件.成功更新文件后,该文件将具有一个新的SHA,您需要先请求该SHA,然后才能再次对其进行更新. (除非,我想,您的下一次更新将在另一个分支上进行.)

So, you can see what the SHA is in the "sha" field of the JSON response. Use that when you formulate your request to update the file with a new version. After you have successfully updated the file, the file will have a new SHA that you will need to request before it can be updated again. (Unless, I guess, your next update goes on a different branch.)

这篇关于如何找到Github文件的SHA Blob的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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