1

on my server "sourcecode" i do :

cd /home/AyamJ/pbGIT
git --bare init

on my local notebook i do :

git push AyamJ@sourcecode:/home/AyamJ/pbGIT master

i got error:

git:'/home/AyamJ/pbGIT' is not a git command. See 'git --help'
fatal: the remote end hung up enexpectedly

on my ~/.ssh/config

Host sourcecode
user AyamJ
port 31313
Host localhost
user Dell
port 22

why that path is interpreted by git?

== UPDATE ==

i have 2 server (by git --bare init) "localhost" and "sourcecode"

i do

GIT_TRACE=1 git push sourcecode:/home/AyamJ/pbGIT master

got 

trace: built-in : git 'push' 'sourcecode:/home/AyamJ/pbGIT' 'master'
trace: run_command : 'ssh' 'sourcecode' 'git-receive-pack '\''/home/AyamJ/pbGIT'\'''

AyamJ@sourcecode's password:
git: '/home/AyamJ/pbGIT' is not a git command. See  'git --help'
fatal: The remote end hung up unexpectedly

and

GIT_TRACE=1 git push localhost:/home/Dell/pbGIT master

got 

trace: built-in : git 'push' 'localhost:/home/Dell/pbGIT' 'master'
trace: run_command : 'ssh' 'localhost' 'git-receive-pack '\''/home/Dell/pbGIT'\'''

Dell@sourcecode's password:
Everything up-to-date

both server has similar cygwin and package.

kreamik
  • 609
  • 2
  • 11
  • 24

2 Answers2

2

If you have a config file, then you should use:

git push sourcecode:/home/AyamJ/pbGIT master

After that, try a:

GIT_TRACE=1 git push sourcecode:/home/AyamJ/pbGIT master

And check out "GIT: clone works, remote push doesn't. Remote repository over copssh":
Adding a --receive-pack='git receive-pack' could help.
Or at least, a git config --global remote.origin.receivepack "git receive-pack".
And check if you have a GIT_SSH variable set.

Make sure to try it with the latest Git release to see if the issue persists.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • i do GIT_TRACE=1, got trace:build-in:git 'push' 'sourcecode:/home/AyamJ/pbGIT' 'master', trace:run_command: 'ssh' 'sourcecode' 'git-receive-pack '\''/home/AyamJpbGIT'\''' – kreamik Nov 22 '12 at 07:38
  • @kreamik You can edit your question with a full and complete trace of that command. And try first a `git config --global remote.origin.receivepack "git receive-pack"`. – VonC Nov 22 '12 at 07:44
  • i have add that global config .. and what else clue i should add more? – kreamik Nov 22 '12 at 08:10
  • "Everything up-to-date": it seems your push has worked, hasn't it (For `Dell`)? Is there any right issue (difference in protection) between `Adam` and `Dell` repo directories and parent directories? Why using `sourcecode:` for both? Shouldn't you `localhost:` for Dell (if I read your ssh config file properly)? – VonC Nov 22 '12 at 08:13
  • the only different is : user AyamJ is created by net user "AyamJ password /add /yes and mkpassd -l -u AyamJ >> /etc/passwd" and Dell is really local user. And you're right sourcecode for dell is localhost – kreamik Nov 22 '12 at 08:32
  • @kreamik ok, did you check to protection on /home/AyamJ/... vs. /home/Dell/...? As in http://stackoverflow.com/questions/13425811/git-ssh-authentication/13428529#13428529 – VonC Nov 22 '12 at 08:47
1

Use a relative path

With a relative path it'll probably work:

git push AyamJ@sourcecode:pbGIT master

I'm not sure of the reason, but testing with abs paths it fails for me so that is probably the/part-of-the error for you. But that isn't the normal way to use git.

Be normal

First ensure the ssh config is setup such that you don't need usernames and passwords i.e. this should work:

(notebook)$ ssh sourcecode
...
(server)$

On the local git repo - create a remote that points at the remote server's repository:

(notebook)$ git remote add sourcecode:pbGIT origin
(notebook)$ git push

It is deliberate that last command has no arguments - with a recent version of git it'll give an error message like so:

fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use
   git push --set-upstream origin <current branch name>

The error message is telling you how to make it so you can push/pull with no arguments, therefore execute that command. With an older version of git the command is the same, there's just no error message. After executing this command, e.g.:

git push --set-upstream origin master

from this point forwards it's not necesssary to use arguments with git push and git pull

Do it the other way around

When starting from scratch, or if the remote repository already exists, it's actually easier to do these things the other way around

(notebook)$ ssh sourcecode
...
(sourcecode)$ mkdir x.git
(sourcecode)$ cd x.git
(sourcecode)$ git init --bare
(sourcecode)$ exit
(notebook)$ git clone sourcecode:x.git
Cloning into 'x'...
warning: You appear to have cloned an empty repository.

Note that above, the remote git repository has been created in a folder named whatever.git - this is merely a convention to identify git folders/repositories, it doesn't have any special meaning, though it's likely to be in all examples.

If after that you take a look in the .git/config file on you'll see something like this:

(notebook)$ cd x; more .git/config
    [core]
    repositoryformatversion = 0 
    filemode = true
    bare = false
    logallrefupdates = true
[remote "origin"]
    fetch = +refs/heads/*:refs/remotes/origin/*
    url = sourcecode:x.git
[branch "master"]
    remote = origin
    merge = refs/heads/master

Which indicates that the remote origin points at the sourcecode server, and the one branch that exists, master, tracks the remote origin.

Community
  • 1
  • 1
AD7six
  • 63,116
  • 12
  • 91
  • 123