对空回购中的特定文件进行稀疏签出
Sparse checkout for a specific file on empty repo
我有两个回购协议:ci-test 和 ci-test2。 ci-test repo 包含一个 CI.yaml 文件,而 ci-test2 repo 是空的。使用 mgit,我在两个存储库上仅对 CI.yaml 文件执行稀疏检出,但出现错误 "Sparse checkout leaves no entry on working directory"。我几乎可以肯定会发生这种情况,因为我正在尝试检出 ci-test2 存储库中不包含它的文件。我想知道是否有一种方法可以优雅地处理这个错误,也许通过查看 git read-tree。这只是一个例子,我有比这更多的回购协议,我的 mgit checkout class 对我的回购协议的内容一无所知。有人有想法吗?
甚至在稀疏检出之前,您可以检查远程存储库是否有 CI.yaml
文件:请参阅“How do I check if a file exists in a remote?”。
但是如果你已经获取了存储库(并且只需要检出/restore one file in it), a git cat-file -e
就可以了:
-e
Exit with zero status if <object>
exists and is a valid object.
If <object>
is of an invalid format, exit with non-zero and emits an error on stderr.
我有两个回购协议:ci-test 和 ci-test2。 ci-test repo 包含一个 CI.yaml 文件,而 ci-test2 repo 是空的。使用 mgit,我在两个存储库上仅对 CI.yaml 文件执行稀疏检出,但出现错误 "Sparse checkout leaves no entry on working directory"。我几乎可以肯定会发生这种情况,因为我正在尝试检出 ci-test2 存储库中不包含它的文件。我想知道是否有一种方法可以优雅地处理这个错误,也许通过查看 git read-tree。这只是一个例子,我有比这更多的回购协议,我的 mgit checkout class 对我的回购协议的内容一无所知。有人有想法吗?
甚至在稀疏检出之前,您可以检查远程存储库是否有 CI.yaml
文件:请参阅“How do I check if a file exists in a remote?”。
但是如果你已经获取了存储库(并且只需要检出/restore one file in it), a git cat-file -e
就可以了:
-e
Exit with zero status if
<object>
exists and is a valid object.
If<object>
is of an invalid format, exit with non-zero and emits an error on stderr.