0

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

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

Command 1

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

Getting following error:

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

Command 2

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

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.

Note:

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

UPDATE

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

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
Chelseawillrecover
  • 2,596
  • 1
  • 31
  • 51

1 Answers1

2

From 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.

and

--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

Zloj
  • 2,235
  • 2
  • 18
  • 28
  • 1
    Or, alternatively, `git archive --remote=ssh://git@10.10.10.5/home/git/project.git HEAD local1.json | tar -xf - -O local1.json >local1.json` – kostix Oct 01 '15 at 10:11
  • Amazing guys, that worked. @kostix answer was more precise – Chelseawillrecover Oct 01 '15 at 10:33
  • @Chelseawillrecover It is a good idea to have a glance at the manual before using something. Makes you more conscious about what you are doing and may give an idea about what to expect. – Zloj Oct 01 '15 at 11:03
  • @Zloj Oh well, that was the first thing I did :) anyway thanks for the comment – Chelseawillrecover Oct 02 '15 at 12:08