0

I am trying to implement a simple scenario where I have a git repo on one server and I am able to push this repo to a remote server. After resolving many other issues, I am stuck at the following stage:

On server1, I have a git repo. Now I follow the steps outlined at http://thelucid.com/2008/12/02/git-setting-up-a-remote-repository-and-doing-an-initial-push/

i.e. 1) ssh to remote server 2) create a directory 3) Bare init a repo 4) exit and on local server add remote using the following statement

   git remote add api User@example.com:/Myproj.git

5) Push to remote. (git push -u api master)

The error I get is

git: '/Myproj.git' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

How to fix this? I am using MsysGit 1.7.10 and the ssh server is Cygwin on both the servers.

=======================

Adding output of GIT_TRACE=2 git push -u api master

$ GIT_TRACE=2 git push -u api master
trace: built-in: git 'push' '-u' 'api' 'master'
trace: run_command: 'ssh' 'Administrator@api.example.com' 'git-receive-pack '\''
/Myproj.git'\'''
git: '/Myproj.git' is not a git command. See 'git --help'.
fatal: The remote end hung up unexpectedly

======================

Output of GIT_TRACE=2 git push -u api master (after doing global git config change)

$ GIT_TRACE=2 git push -u api master trace: built-in: git 'push' '-u' 'api' 'master' trace: run_command: 'ssh' 'Administrator@api.example.com' 'git receive-pack '\'' /MyProj.git'\''' fatal: '/MyProj.git' does not appear to be a git repository fatal: The remote end hung up unexpectedly

shashi
  • 4,616
  • 9
  • 50
  • 77

1 Answers1

2

I think all you need is to remove a slash and run:

git remote add api User@example.com:Myproj.git
xaizek
  • 5,098
  • 1
  • 34
  • 60
  • I have also tried giving the full path as suggested here http://stackoverflow.com/questions/11571173/unable-to-push-to-remote-git-repository-does-not-appear-to-be-a-git-re but I get the same error, just with a different path. – shashi Jul 23 '12 at 19:42
  • Add output of `GIT_TRACE=2 git push -u api master` to the question. It will show more information. – xaizek Jul 23 '12 at 19:57
  • You may need to run `git config --local remote.api.receivepack "git receive-pack"` for local repository as suggested [here](http://stackoverflow.com/a/2745562/1535516) – xaizek Jul 23 '12 at 20:03
  • And how did the output of `GIT_TRACE=2 ...` change? – xaizek Jul 23 '12 at 20:13
  • Sorry, the error now was different, didn't notice that earlier. It now says /MyProj.git does not appear to be a git repository. – shashi Jul 23 '12 at 20:26
  • Either the path is incorrect (maybe try to use full path) or the directory is really not a repository (if you accidentally inited wrong directory). – xaizek Jul 23 '12 at 20:29
  • 1
    I removed the colon from the path and it worked then. Thanks for also showing how to debug. Learn a thing or two today. – shashi Jul 23 '12 at 20:52