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
  • 145
  • 6
  • you are missing `:` divisor between host and path in `sudo git remote add testy ssh://user@server:/mnt/test.git` – Jakuje Jul 21 '15 at 18:13
  • 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 Jul 21 '15 at 18:29
  • 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 Jul 21 '15 at 19:07

1 Answers1

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
  • 7,171
  • 4
  • 33
  • 54
  • 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 Jul 21 '15 at 17:37
  • Run chown recursively to make sure the user can read/write all necessary files: `sudo chown -R user /mnt/test.git`. – umläute Jul 21 '15 at 18:19
  • 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 Jul 21 '15 at 19:07
  • @MeesterTeem A bare repository by definition does not have checked out copies of the files, if that is what you mean. – l0b0 Jul 21 '15 at 19:43
  • 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 Jul 21 '15 at 20:09
  • 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 Jul 21 '15 at 20:58