1

I sometimes use my local git repository to track changes I make before submitting it to our official project git repository.
I'm doing the same thing for a new project on a Ubuntu 16.04 machine now, but this time, because the working directory and my local repository is in the same hard disk (both in /dev/sdb1), if the hard disk fails, I won't be able to recover the data. This makes me feel uneasy, so I thought I should move the repository to another machine I own(It's Centos 6.9 machine) because I don't have another hard disk installed in the Ubuntu current machine.
So I tar'ed the ProjS.git directory (repository) from the Ubuntu machine, and ftp'd it to my CentOS machine and untar'ed it on /home2/repos.ProjS.git in the CentOS machine. And in the ubuntu machine's ~/testgit directory, I tried

ckim@chan-ubuntu:~/testgit$ git clone ssh://ckim@129.254.xxx.yyy/home2/repos/ProjS.git/
Cloning into 'ProjS'...
ckim@129.254.xxx.yyy's password: 
fatal: protocol error: bad line length character: ----
ckim@chan-ubuntu:~/testgit$ fatal: The remote end hung up unexpectedly

The CentOS mahcine has never been used as a git repository for external machines. (But it had served as git repository for internal users, actually the same user me). In this case, what should I do? (maybe I should give access permission to myself.)

Chan Kim
  • 5,177
  • 12
  • 57
  • 112
  • why wouldnt you make a branch(something like 'backup') with your code and then pull it from the new machine? – berlin Feb 22 '21 at 07:55
  • @berlin branch or not, the problem is pulling from another machine. The repos was pull only at the local machine. Now I want to put the repos in a remote machine and pull it from my current machine(ubuntu). – Chan Kim Feb 22 '21 at 08:07

1 Answers1

1

Instead of tar'ing the repository, I would use the git bundle command (as I described in "Fully backup a git repo?")

That will result in one file that you can copy over (scp for a copy over SSH), and clone.

 git clone myrepo.bundle

Once cloned, you can add the original repo SSH URL, but make sure to generate an SSH key, and register the public one to the original server.

ssh-keygen -t rsa -P""
# copy ~/.ssh/id_rsa.pub in 129.254.xxx.yyy:/home/ckim/.ssh/authorized_keys

That way, no password to ask.
Make sure the ~/.bashrc or ~/.profile in /home/ckin is silent (does not output strings)

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Thank you. this works! (I just used the tar'ed repos so it wasn't crucial). Two important things were the ssh key thing(I expected something like this) and removing a print coming out from the .cshrc in CentOS account(maybe this was the direct problem, because .cshrc spat out ---- pattern.). Thank you very much! – Chan Kim Feb 22 '21 at 08:53