Git commit over SSH not recognizing remote repository

2

I have 2 machines, client and server. I want to send git repositories from client to server, using remote push. I've run these commands in this order on the server:

mkdir /mnt && cd /mnt
mkdir test.git && cd test.git
sudo git init --bare

I've run these commands on the client:

mkdir /mnt && cd /mnt
mkdir test.git && cd test.git
sudo git init
sudo git remote add testy ssh://user@server/mnt/test.git
sudo vim testing.txt
sudo git add testing.txt
sudo git commit -m "testing"
sudo git push testy master

This produces the error on the client machine: fatal: '/mnt/test.git' does not appear to be a git repository. fatal: The remote end hung up unexpectedly.

There are several similar questions, but none of them address my problem. I've tried their solutions verbatim without success. This isn't a duplicate, because those answers do not solve the issue. Any suggestions to fix these problems?

MeesterTeem

Posted 2015-07-21T15:02:03.623

Reputation: 145

you are missing : divisor between host and path in sudo git remote add testy ssh://user@server:/mnt/test.git – Jakuje – 2015-07-21T18:13:01.213

you are totally overusing sudo, effectively breaking all permissions (and not noticing because you override them). you shoud only use sudo for commands that require special privileges (e.g. creating the directory /mnt/test.git); actually, in your example every single use of sudo is unneccessary and therefore most likely bad. – umläute – 2015-07-21T18:29:04.040

If i put a colon such that i have sudo git remote add testy ssh://user@server:/mnt/test.git i get the error: hostname server:: cannot be resolved. – MeesterTeem – 2015-07-21T19:07:08.177

Answers

1

I would guess user@server does not have read/write/execute access to /mnt/test.git:

$ sudo sh -c 'cd $(mktemp -d) && git init --bare'
Initialized empty Git repository in /tmp/tmp.TNLcXTZQcN/
$ cd $(mktemp -d)
$ git remote add /tmp/tmp.TNLcXTZQcN
fatal: Not a git repository (or any parent up to mount point /tmp)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).

l0b0

Posted 2015-07-21T15:02:03.623

Reputation: 6 306

I used chown to give user access to the directory. Now I get: fatal: not a git repository (or any of the parent directories) : .git Any more suggestions? – MeesterTeem – 2015-07-21T17:37:34.450

Run chown recursively to make sure the user can read/write all necessary files: sudo chown -R user /mnt/test.git. – umläute – 2015-07-21T18:19:10.903

I've gotten everything finally to where the push was accepted- but the file i added as a test does not appear to be sent. Is this likely still a write permissions issue? – MeesterTeem – 2015-07-21T19:07:59.043

@MeesterTeem A bare repository by definition does not have checked out copies of the files, if that is what you mean. – l0b0 – 2015-07-21T19:43:02.563

There seems to be a big problem then.... a bare repo doesn't check files out, so you can't push content to it. A non-bare repo has the master branch checked out so you can't push to it either! What is even the point of that? And why does every guide to setting up remote file deployment use a bare one if they can't get files? – MeesterTeem – 2015-07-21T20:09:25.233

No, you can push content to it. And you can get the files from it by cloning into a non-bare repository. It just won't be checked out on the server. The point of that is for example for hosting. – l0b0 – 2015-07-21T20:58:42.487