简体   繁体   中英

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/

ie 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

我认为您只需要删除斜杠并运行:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM