Search code examples
gitpushmsysgit

Unable to push to remote repository in Git


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


Solution

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

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