Git:我如何将使用git hash-object创建的对象回推到原点? [英] Git: How do I push objects created with git hash-object back to origin?

查看:103
本文介绍了Git:我如何将使用git hash-object创建的对象回推到原点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用git笔记来存储一些(小)数据块。我几乎有它的工作,但我试图将数据提取到另一台机器时遇到麻烦。



我使用 git hash -object 并将返回的散列存储在注释中。

  git hash-object -w timestamp。 signed.tsr | git notes --ref = timestamps add --file  -  

我可以推送并获取包含哈希使用自我注释中概述的方法。

  git push origin refs / notes / timestamps 
git fetch origin refs / notes / *:refs / notes / *

然而,我无法弄清楚如何获得blob对象。我很确定我的blob对象没有被推到原点。我检查的方式是在推送 0dd470d2fc5556de62d813537fd483aede2f6b35 (这应该是blob对象的散列)的注释之后,我使用裸仓库转至机器并查找对象/ 0D / d470d2fc5556de62d813537fd483aede2f6b35 。因为它不在那里,所以我认为它永远不会被推送。



有没有简单的我忽略了我需要做的事git知道blob对象被引用笔记?将数据直接存储在笔记中会更好吗?请问base64对数据进行编码并将其直接存储在笔记中会更好吗?



请注意任何提示。


I'm trying to use git notes to store some (small) blobs of data. I almost have it working, but I'm having trouble when I try to fetch the data to another machine.

I'm using git hash-object and storing the returned hash in the note.

git hash-object -w timestamp.signed.tsr | git notes --ref=timestamps add --file -

I can push and fetch the notes that contain the hashes using the method outlined in Note to Self.

git push origin refs/notes/timestamps
git fetch origin refs/notes/*:refs/notes/*

However, I can't figure out how to get the blob objects to go along with it. I'm fairly certain my blob objects aren't getting pushed to origin. The way I'm checking is after pushing a note of 0dd470d2fc5556de62d813537fd483aede2f6b35, which should be the hash of a blob object, I go to the machine with my bare repository and look for objects/0d/d470d2fc5556de62d813537fd483aede2f6b35. Since it's not there, I assume it's never getting pushed.

Is there something simple I'm overlooking that I need to do so git knows the blob objects are referenced by the notes? Would it be better to store the data directly in the note? Would it be better to base64 encode the data and store it directly in the note?

Any tips would be appreciated.

解决方案

Notes can contain arbitrary data, they are not required or even expected to contain references to other objects. For that reason git will not interpret note contents as references. Since the commands that you have shown would not create an references to your hashed object, that object would not be pushed to a different repository. In fact the object would be eligible for garbage collection once it becomes old enough.

这篇关于Git:我如何将使用git hash-object创建的对象回推到原点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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