无法从远程git服务器提取单个文件 [英] Not able to extract single file from remote git server

查看:196
本文介绍了无法从远程git服务器提取单个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am asking this question because I have tried every single answer posted in the forum but none worked for me.

我尝试了以下答案,以从远程Git存储库下载单个文件"testfile.txt",但没有用:

I tried the following answers to download a single file "testfile.txt" from remote Git repository but none worked:

命令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密码,而该密码不存在.

Error: This prompts for my ssh key password which I entered but then it prompts me for root password afterwards and that does not exist.

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

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

So at this stage I am wondering what I have done wrong. Any help will be appreciated.

注意:

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

I am connecting from my local server as root and accessing the git server which has a git user account

更新

我对其中一个命令做了如下更改:

I made some changes to one of the commands as follows:

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

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

this prompts for ssh key and then I get following but can't find the file

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

推荐答案

来自 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`

所以您要执行以下操作:

so you want to do the following:

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

这篇关于无法从远程git服务器提取单个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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