threads / discuss / 8678

problem pushing repository

Subject: problem pushing repository

## tl;dr

15 messages between Jun 22, 2007 and Jun 25, 2007.

replies: 14people: 8as markdown or json

Adam Mercer· Jun 22, 2007, 01:49 UTC · lore
Hi

I've just started using git to track a project I'm working on and I'm having a problem pushing my repository.

[ram@skymoo glue]$ git push ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git bash: line 1: git-receive-pack: command not found fatal: The remote end hung up unexpectedly error: failed to push to 'ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git' [ram@skymoo glue]$ which git-receive-pack /Users/ram/opt/git/bin/git-receive-pack [ram@skymoo glue]$

git-receive-pack is in my $PATH so why can't it be found when trying to push?
Cheers
Adam
Junio C Hamano· Jun 22, 2007, 02:00 UTC · re: Adam Mercer · lore

Re: problem pushing repository

"Adam Mercer" <ramercer@gmail.com> writes:
Show 11 quoted lines
> [ram@skymoo glue]$ git push
> ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git
> bash: line 1: git-receive-pack: command not found
> fatal: The remote end hung up unexpectedly
> error: failed to push to
> 'ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git'
> [ram@skymoo glue]$ which git-receive-pack
> /Users/ram/opt/git/bin/git-receive-pack
> [ram@skymoo glue]$
>
> git-receive-pack is in my $PATH so why can't it be found when trying to push?

Check your ssh and ssh server settings. Often the process invoked from non-interactive ssh connection (such as the attempt to invoke receive-pack) would not get the PATH you set up in ~/.login or ~/.bash_profile.

	$ ssh newberry.ihepa.ufl.edu sh -c 'echo $PATH'

may be a good starting point to test this, and the first step to fix it would be

	$ man ssh
	$ man sshd
Andrew Ruder· Jun 22, 2007, 02:24 UTC · re: Junio C Hamano · lore

Re: problem pushing repository

On Thu, Jun 21, 2007 at 07:00:18PM -0700, Junio C Hamano wrote:
Show 7 quoted lines
> 	$ ssh newberry.ihepa.ufl.edu sh -c 'echo $PATH'
> 
> may be a good starting point to test this, and the first step
> to fix it would be
> 
> 	$ man ssh
> 	$ man sshd
While I wholeheartedly agree with Junio here, you may also find
remote.<name>.receivepack
useful, see git-push(1) and git-config(1) for more information.
- Andy
-- 
Andrew Ruder <andy@aeruder.net>
http://www.aeruder.net
Raimund Bauer· Jun 22, 2007, 07:21 UTC · re: Andrew Ruder · lore

Re: problem pushing repository

On Thu, 2007-06-21 at 21:24 -0500, Andrew Ruder wrote:
Show 12 quoted lines
> On Thu, Jun 21, 2007 at 07:00:18PM -0700, Junio C Hamano wrote:
> > 	$ ssh newberry.ihepa.ufl.edu sh -c 'echo $PATH'
> > 
> > may be a good starting point to test this, and the first step
> > to fix it would be
> > 
> > 	$ man ssh
> > 	$ man sshd
> 
> While I wholeheartedly agree with Junio here, you may also find
> 
> remote.<name>.receivepack

Yes, but it doesn't always work. I have a server with several repositories, and git is installed in /usr/local/bin. All my local repostories know this server as a remote named 'slcom' and I have a 2 global options remote.slcom.uploadpack=/usr/local/bin/git-upload-pack remote.slcom.receivepack=/usr/local/bin/git-receive-pack

Fetching, pulling and normal pushing works. Pushing a new branch to the remote doesn't work: $ git branch test $ git push slcom test:test error: dst refspec test does not match any existing ref on the remote and does not start with refs/. fatal: The remote end hung up unexpectedly error: failed to push to 'ray@softwarelandschaft.com:/home/ray/repos/drupal/multirate'

git-remote also has a problem: $ git remote show slcom bash: git-upload-pack: command not found fatal: The remote end hung up unexpectedly ls-remote --heads ray@softwarelandschaft.com:/home/ray/repos/drupal/multirate: command returned error: 1

All this with git from yesterday (next).
> - Andy
-- 
best regards

  Ray
Johannes Schindelin· Jun 22, 2007, 11:26 UTC · re: Raimund Bauer · lore

Re: problem pushing repository

Hi,
On Fri, 22 Jun 2007, Raimund Bauer wrote:
Show 6 quoted lines
> $ git push slcom test:test 
> error: dst refspec test does not match any existing ref on the remote
> and does not start with refs/.
> fatal: The remote end hung up unexpectedly
> error: failed to push to
> 'ray@softwarelandschaft.com:/home/ray/repos/drupal/multirate'
This is a completely unrelated problem!

It says that there is no branch named "test" on the remote side, and since you could also want to push a tag, you have to say

	test:refs/heads/test

here. However, I do not understand why you bother to use the :dst syntax here, since your target name is _exactly_ the same as the source name. Why not just

	git push slcom test
Hm??
Show 7 quoted lines
> git-remote also has a problem:
> $ git remote show slcom
> bash: git-upload-pack: command not found
> fatal: The remote end hung up unexpectedly
> ls-remote --heads
> ray@softwarelandschaft.com:/home/ray/repos/drupal/multirate: command
> returned error: 1
That's apparently a bug in git-remote.

Ciao, Dscho

Raimund Bauer· Jun 22, 2007, 13:38 UTC · re: Johannes Schindelin · lore

Re: problem pushing repository

Hi,
On Fri, 2007-06-22 at 12:26 +0100, Johannes Schindelin wrote: 
Show 23 quoted lines
> Hi,
> 
> On Fri, 22 Jun 2007, Raimund Bauer wrote:
> 
> > $ git push slcom test:test 
> > error: dst refspec test does not match any existing ref on the remote
> > and does not start with refs/.
> > fatal: The remote end hung up unexpectedly
> > error: failed to push to
> > 'ray@softwarelandschaft.com:/home/ray/repos/drupal/multirate'
> 
> This is a completely unrelated problem!
> 
> It says that there is no branch named "test" on the remote side, and since 
> you could also want to push a tag, you have to say
> 
> 	test:refs/heads/test
> 
> here. However, I do not understand why you bother to use the :dst syntax 
> here, since your target name is _exactly_ the same as the source name. Why 
> not just
> 
> 	git push slcom test

because I had gotten the command line from bash-completion and since it worked with existing branches I saw no reason why it shouldn't work with new ones. will read the documentation next time ;-)

> Ciao,
> Dscho
-- 
best regards

  Ray
Shawn O. Pearce· Jun 22, 2007, 22:47 UTC · re: Raimund Bauer · lore

Re: problem pushing repository

Raimund Bauer <ray007@gmx.net> wrote:
Show 19 quoted lines
> On Fri, 2007-06-22 at 12:26 +0100, Johannes Schindelin wrote: 
> > On Fri, 22 Jun 2007, Raimund Bauer wrote:
> > 
> > > $ git push slcom test:test 
> > > error: dst refspec test does not match any existing ref on the remote
> > > and does not start with refs/.
> > 
> > It says that there is no branch named "test" on the remote side, and since 
> > you could also want to push a tag, you have to say
> > 
> > 	test:refs/heads/test
> > 
> > here. However, I do not understand why you bother to use the :dst syntax 
> > here, since your target name is _exactly_ the same as the source name. Why 
> > not just
> > 
> > 	git push slcom test
> 
> because I had gotten the command line from bash-completion

I just patched the bash completion package to offer `git push slcom test` as the completion, instead of `git push slcom test:test`. The patch was pretty trivial, and is now also in my fastimport.git tree on repo.or.cz.

-->8-- Avoid src:dst syntax as default bash completion for git push

Raimund Bauer just discovered that the default bash completion for a local branch name in a git-push line is not the best choice when the branch does not exist on the remote system.

In the past we have always completed the local name 'test' as "test:test", indicating that the destination name is the same as the local name. But this fails when "test" does not yet exist on the remote system, as there is no "test" branch for it to match the name against.

Fortunately git-push does the right thing when given just the local branch, as it assumes you want to use the same name in the destination repository. So we now offer "test" as the completion in a git-push line, and let git-push assume that is also the remote branch name.

We also still support the remote branch completion after the :, but only if the user manually adds the colon before trying to get a completion.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/completion/git-completion.bash |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index 9e72f0f..c7c9963 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -683,7 +683,7 @@ _git_push ()
 			__gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
 			;;
 		*)
-			__gitcomp "$(__git_refs2)"
+			__gitcomp "$(__git_refs)"
 			;;
 		esac
 		;;
-- 
1.5.2.2.1050.g51a8b

-- 
Shawn.
Raimund Bauer· Jun 23, 2007, 10:12 UTC · re: Shawn O. Pearce · lore

Re: problem pushing repository

Hi,
On Fri, 2007-06-22 at 18:47 -0400, Shawn O. Pearce wrote:
> Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> ---
>  contrib/completion/git-completion.bash |    2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)

Thanks a lot, your patch makes my life easier. Since you obviously know what you're doing here, maybe I can wish for something too?

It would be really cool if completion also worked when I started the branchname with a '+' to force the push ...

-- 
best regards

  Ray
Shawn O. Pearce· Jun 24, 2007, 23:47 UTC · re: Raimund Bauer · lore

Re: problem pushing repository

Raimund Bauer <ray007@gmx.net> wrote:
Show 9 quoted lines
> On Fri, 2007-06-22 at 18:47 -0400, Shawn O. Pearce wrote:
> > Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
> > ---
> >  contrib/completion/git-completion.bash |    2 +-
> >  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> Thanks a lot, your patch makes my life easier.
> Since you obviously know what you're doing here, maybe I can wish for
> something too?

Heh, sure. I wrote that "stock" bash completion package, but at this point I largely consider it to be "complete and stable" and therefore don't put a lot of effort into it anymore.

This recent thread has been interesting, as it has uncovered two
bugs related to the git-push completion.
 
> It would be really cool if completion also worked when I started the
> branchname with a '+' to force the push ...
How does this work?  ;-)
I'm pushing it out to my fastimport tree shortly.

-->8-- Teach bash how to complete +refspec on git-push

Using `git push origin +foo` to forcefully overwrite the remote branch named foo is a common idiom, especially since + is shorter than the long option --force and can be specified on a per-branch basis.

We now complete `git push origin +foo` just like we do the standard `git push origin foo`. The leading + on a branch refspec does not alter the completion.

Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
---
 contrib/completion/git-completion.bash |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)
diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash
index c7c9963..f2b10fa 100755
--- a/contrib/completion/git-completion.bash
+++ b/contrib/completion/git-completion.bash
@@ -682,6 +682,9 @@ _git_push ()
 			esac
 			__gitcomp "$(__git_refs "$remote")" "" "${cur#*:}"
 			;;
+		+*)
+			__gitcomp "$(__git_refs)" + "${cur#+}"
+			;;
 		*)
 			__gitcomp "$(__git_refs)"
 			;;
-- 
1.5.2.2.1334.g1625


-- 
Shawn.
Jakub Narebski· Jun 25, 2007, 01:01 UTC · re: Shawn O. Pearce · lore

Re: problem pushing repository

Shawn O. Pearce wrote:
> Heh, sure.  I wrote that "stock" bash completion package, but at
> this point I largely consider it to be "complete and stable" and
> therefore don't put a lot of effort into it anymore.

One thing that annoys me greatly (and I think I use newest completion) is that sometimes _filename_ completion gets confused on the '.' separating basename and extension, and instead of completing extension it adds another dot to make range operator '..' and triec to complete branch name, even if basename is _not_ any branch name.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Adam Mercer· Jun 22, 2007, 13:36 UTC · re: Andrew Ruder · lore

Re: problem pushing repository

On 21/06/07, Andrew Ruder <andy@aeruder.net> wrote:
Show 14 quoted lines
> On Thu, Jun 21, 2007 at 07:00:18PM -0700, Junio C Hamano wrote:
> >       $ ssh newberry.ihepa.ufl.edu sh -c 'echo $PATH'
> >
> > may be a good starting point to test this, and the first step
> > to fix it would be
> >
> >       $ man ssh
> >       $ man sshd
>
> While I wholeheartedly agree with Junio here, you may also find
>
> remote.<name>.receivepack
>
> useful, see git-push(1) and git-config(1) for more information.

This seems like the best way to fix this issue, however it isn't clear from the man page what I need to put in my ~/.gitconfig. With the following in .gitconfig

[remote] glue.receivepack = /home/ram/opt/git/bin/git-receive-pack

I get the following error when trying to push

[ram@skymoo glue]$ git push ssh://newberry.ihepa.ufl.edu/~/public_html/git/glue.git fatal: bad config file line 6 in /Users/ram/.gitconfig

so this is clearly not the right entry. Can someone please give me a push in the right direction?

Cheers
Adam
Raimund Bauer· Jun 22, 2007, 14:17 UTC · re: Adam Mercer · lore

Re: problem pushing repository

On Fri, 2007-06-22 at 09:36 -0400, Adam Mercer wrote:
Show 6 quoted lines
> This seems like the best way to fix this issue, however it isn't clear
> >from the man page what I need to put in my ~/.gitconfig. With the
> following in .gitconfig
> 
> [remote]
> glue.receivepack = /home/ram/opt/git/bin/git-receive-pack
In my config it looks like this:
[remote "slcom"]
        uploadpack = /usr/local/bin/git-upload-pack
        receivepack = /usr/local/bin/git-receive-pack
-- 
best regards

  Ray
Adam Mercer· Jun 22, 2007, 14:32 UTC · re: Raimund Bauer · lore

Re: problem pushing repository

On 22/06/07, Raimund Bauer <ray007@gmx.net> wrote:
Show 5 quoted lines
> In my config it looks like this:
>
> [remote "slcom"]
>         uploadpack = /usr/local/bin/git-upload-pack
>         receivepack = /usr/local/bin/git-receive-pack
putting
[remote "glue"]
  uploadpack = /home/ram/opt/git/bin/git-upload-pack
  receivepack = /home/ram/opt/git/bin/git-receive-pack

in my .gitconfig I still get the error saying that git-receive-pack can't be found. If I specify the path on the git push command line using the --exec option then git-receive-pack is found, so it appears that my config file isn't being read.

Cheers
Adam
Adam Mercer· Jun 22, 2007, 13:23 UTC · re: Junio C Hamano · lore

Re: problem pushing repository

On 21/06/07, Junio C Hamano <gitster@pobox.com> wrote:
Show 26 quoted lines
> "Adam Mercer" <ramercer@gmail.com> writes:
>
> > [ram@skymoo glue]$ git push
> > ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git
> > bash: line 1: git-receive-pack: command not found
> > fatal: The remote end hung up unexpectedly
> > error: failed to push to
> > 'ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git'
> > [ram@skymoo glue]$ which git-receive-pack
> > /Users/ram/opt/git/bin/git-receive-pack
> > [ram@skymoo glue]$
> >
> > git-receive-pack is in my $PATH so why can't it be found when trying to push?
>
> Check your ssh and ssh server settings.  Often the process
> invoked from non-interactive ssh connection (such as the attempt
> to invoke receive-pack) would not get the PATH you set up in ~/.login
> or ~/.bash_profile.
>
>         $ ssh newberry.ihepa.ufl.edu sh -c 'echo $PATH'
>
> may be a good starting point to test this, and the first step
> to fix it would be
>
>         $ man ssh
>         $ man sshd
Thanks Junio thats the problem my path isn't being set correctly on newberry
[ram@skymoo ram]$ ssh newberry sh -c 'echo $PATH'

[ram@skymoo ram]$ ssh newberry [ram@newberry ram]$ which git-receive-pack ~/opt/git/bin/git-receive-pack [ram@newberry ram]$

Cheers
Adam
Johannes Sixt· Jun 22, 2007, 07:20 UTC · re: Adam Mercer · lore

Re: problem pushing repository

Adam Mercer wrote:
Show 11 quoted lines
> [ram@skymoo glue]$ git push
> ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git
> bash: line 1: git-receive-pack: command not found
> fatal: The remote end hung up unexpectedly
> error: failed to push to
> 'ssh://ram@newberry.ihepa.ufl.edu/~ram/public_html/git/glue.git'
> [ram@skymoo glue]$ which git-receive-pack
> /Users/ram/opt/git/bin/git-receive-pack
> [ram@skymoo glue]$
> 
> git-receive-pack is in my $PATH so why can't it be found when trying to push?
You must have git installed on the remote end, too.
-- Hannes

← back to recent threads