1

So I'm new to both git and ssh, so some basic terminology might be wrong in what I'm saying.

I'm trying to copy (with scp) my repository (I also backup this repo via github,so it has a .git folder) to a remote machine that I access via ssh.

It always worked before.

Then I added another branch from master and kept working on the code on that new branch.
I don't know of anything other I changed that could be significant here.

Anyways, now the old scp -r command to copy the repository to the remote machine uploads my normal files but it fails in ".git/objects":

scp: /scratch/petzi/remote/meins/.git/objects/43/50c1b2c7306710fad08153c12fd4a394aef0fc: 
     Permission denied

And the equivalent message for all kinds of files (maybe even all, I haven't checked) in "objects".

How can I get past those error messages?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250

2 Answers2

1

Instead of using scp, to copying every single files, use git bundle, and scp only one file. Less errors.

cd /path/to/local/myrepo
git bundle create ../myrepo.bundle --all
scp ../myrepo.bundle remoteUser@remoteServer:~/myrepo.bundle

On the remote server:

cd /path/to/myrepo
git remote add bundle /home/remoteUser/myrepo.bundle
git fetch bundle
git switch master
git merge bundle/master

You can clone or fetch from a bundle, which (again) is one file representing your repository.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
1

Why do you scp -r the full repository each time? Git has been developed to synchronize the code between multiple machines, but you are using scp do to it (although you are using git).

If you want to keep code synchronized between two machines and you already have a git repository in github, then just use the github repository as a canonical repository to synchronice your machines.

Asumming you already have a git repository in the remote machine. After you made changes in your local machine:

  1. commit your code
  2. push your code to github (something like git push origin master)
  3. ssh to your machine
  4. cd to the git repository path
  5. get your code from github (something like git pull origin master)
fifoq
  • 183
  • 13