【问题标题】:Not able to extract single file from remote git server无法从远程 git 服务器中提取单个文件
【发布时间】:2015-10-01 09:13:56
【问题描述】:

我问这个问题是因为我已经尝试了论坛上发布的每一个答案,但没有一个对我有用。

我尝试了以下答案以从远程 Git 存储库下载单个文件“testfile.txt”,但均未奏效:

命令 1

git archive --remote=git://10.10.10.5/project.git HEAD testfile

出现以下错误:

errno=Connection timed out
fatal: unable to connect a socket (Connection timed out)

命令 2

git archive --remote=ssh://10.10.10.5/project.git HEAD testfile

错误:这会提示我输入我输入的 ssh 密钥密码,但之后会提示我输入 root 密码,但该密码不存在。

Enter passphrase for key '/root/.ssh/id_rsa':
root@10.10.10.5's password:
Permission denied, please try again.

所以在这个阶段我想知道我做错了什么。任何帮助将不胜感激。

注意:

我以 root 身份从本地服务器连接并访问具有 git 用户帐户的 git 服务器

更新

我对其中一个命令进行了一些更改,如下所示:

git archive --remote=ssh://git@10.10.10.5/home/git/project.git HEAD local1.json

这提示输入 ssh 密钥,然后我得到关注但找不到文件

Enter passphrase for key '/root/.ssh/id_rsa':
pax_global_header0000666000000000000000000000006412603247310088520gustar00rootroot0000000000000052 comment=e5c6e52614cccd39797bc17e7d11c4d2f7893b18
local1.json000066400000000000000000000000131260276633100131240ustar00rootroot00000000000000V2 updated

【问题讨论】:

    标签: git repository


    【解决方案1】:

    来自git-archive man

    Creates an archive of the specified format containing the tree structure for the named tree, and writes it out to the standard output.

    --format=<fmt>

    Format of the resulting archive: tar or zip. If this option is not given, and the output file is specified, the format is inferred from the filename if possible (e.g. writing to "foo.zip" makes the output to be in the zip format). Otherwise the output format is tar`
    

    所以你想做以下事情:

    git archive --remote=ssh://git@10.10.10.5/home/git/project.git HEAD local1.json > archived_file.tar

    【讨论】:

    • 或者,git archive --remote=ssh://git@10.10.10.5/home/git/project.git HEAD local1.json | tar -xf - -O local1.json >local1.json
    • 很棒的家伙,这很有效。 @kostix 的回答更准确
    • @Chelseawillrecover 在使用某些东西之前先看一下手册是个好主意。让您更清楚自己在做什么,并可能对预期的结果有所了解。
    • @Zloj 哦,好吧,那是我做的第一件事 :) 无论如何感谢您的评论
    猜你喜欢
    • 1970-01-01
    • 2015-04-07
    • 1970-01-01
    • 2016-10-19
    • 2023-03-05
    • 2013-05-03
    • 1970-01-01
    • 2011-04-08
    • 2012-06-15
    相关资源
    最近更新 更多