git push from localhost seems to use different git command

58 views
Skip to first unread message

Daniel Dietsch

unread,
Feb 5, 2020, 8:38:28 AM2/5/20
to gito...@googlegroups.com
Hi everyone,
I have a problem using gitolite from the machine on which I am hosting it (I am running gitolite-3.6.11 on git 2.24.1).

I have a repository called my-repo, its cloned to some path on the machine which also hosts gitolite.
If I look at the remote, I see the following.
--
# git remote show origin
* remote origin
Fetch URL: ssh://git@localhost/my-repo.git
Push URL: ssh://git@localhost/my-repo.git
HEAD branch: master
Remote branch:
master tracked
Local branch configured for 'git pull':
master merges with remote master
Local ref configured for 'git push':
master pushes to master (up to date)
--

If I try to push, I get this:
--
# git push
FATAL: unknown git/gitolite command: 'git receive-pack '/my-repo.git''
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
--

But, if I push directly to the URL, i.e. with
git push ssh://git@localhost/my-repo.git master:master
everything works.

Looking into the gitolite logs for both pushes shows the following:
--
8500 ssh ARGV=XXX SOC=git receive-pack '/my-repo.git' FROM=127.0.0.1
8500 die unknown git/gitolite command: 'git receive-pack '/my-repo.git''
8778 ssh ARGV=XXX SOC=git-receive-pack '/my-repo.git' FROM=127.0.0.1
8778 pre_git my-repo XXX W any refs/.*
8778 system,git,shell,-c,git-receive-pack '.../repositories/my-repo.git'
8778 update my-repo XXX W refs/heads/master 3a286a10145d33c4cfa04897918a91bfeb046414
afb20d6a773f13f5b198ad9f09b543c78eb616fc refs/.*
8778 END
--

Note that the first case tries to use
git receive-pack
and the second uses
git-receive-pack

Does anybody knows how I can fix this?

Best,
Daniel



signature.asc

Björn Kautler

unread,
Feb 5, 2020, 8:50:54 AM2/5/20
to Daniel Dietsch, gitolite
Maybe you get more insight if you set the environment variable GIT_TRACE=1 when calling `git`, it then shows what it does internally.

Cheers
Björn

--
You received this message because you are subscribed to the Google Groups "gitolite" group.
To unsubscribe from this group and stop receiving emails from it, send an email to gitolite+u...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/gitolite/dcae9e7a-332e-894d-99da-d745fc60ff78%40informatik.uni-freiburg.de.

Sitaram Chamarty

unread,
Feb 5, 2020, 8:57:42 AM2/5/20
to Daniel Dietsch, gito...@googlegroups.com
NOTE to the denizens of this list: do any of you have any ideas?
I have no clue what's going on; read below.

On Tue, Feb 04, 2020 at 06:11:47PM +0100, Daniel Dietsch wrote:

> Push URL: ssh://git@localhost/my-repo.git

> # git push
> FATAL: unknown git/gitolite command: 'git receive-pack '/my-repo.git''
> fatal: Could not read from remote repository.

> But, if I push directly to the URL, i.e. with
> git push ssh://git@localhost/my-repo.git master:master
> everything works.

> Looking into the gitolite logs for both pushes shows the following:

[...]

> Note that the first case tries to use
> git receive-pack
> and the second uses
> git-receive-pack
>
> Does anybody knows how I can fix this?

I tried several different ways, and I cannot reproduce this
behaviour (i.e., make my git client call out "git receive-pack"
instead of "git-receive-pack")

Could you try this:

- add something like this to you ~/.ssh/config

host mygit
user git
hostname localhost

- make a fresh clone by running:

git clone mygit:my-repo.git

- cd my-repo, make some changes, commit, and try push.

TBH, I'm grasping at straws here; I have no idea why (or, more
to the point, *under what conditions*) the git client would
choose to do this.

sitaram

Tony Finch

unread,
Feb 5, 2020, 9:39:06 AM2/5/20
to Sitaram Chamarty, Daniel Dietsch, gito...@googlegroups.com
Sitaram Chamarty <sita...@gmail.com> wrote:

> NOTE to the denizens of this list: do any of you have any ideas?

As far as I can tell from reading git's code, the `git-receive-pack`
command can be changed either by the remote.<name>.receivepack config
option, or by the `git push --receive-pack=` option. So perhaps catting
`.git/config` will yield a clue. (The receivepack option isn't printed by
`git remote show`.)

Otherwise, run it under strace with fully verbose strings and see if it is
reading `git receive-pack` somewhere before it spawns ssh :-)

Tony.
--
f.anthony.n.finch <d...@dotat.at> http://dotat.at/
champion the freedom, dignity, and well-being of individuals

Daniel Dietsch

unread,
Feb 5, 2020, 11:02:46 AM2/5/20
to gito...@googlegroups.com
Hi Everyone,
thank you for your help!

TL;DR: It was a git config setting, specifically remote.origin.receivepack.

I tried GIT_TRACE=1 first, and did see the following.
# GIT_TRACE=1 git push
16:52:27.077870 git.c:439 trace: built-in: git push
16:52:27.078656 run-command.c:663 trace: run_command: unset GIT_PREFIX; ssh git@localhost 'git receive-pack
'\''/my-repo.git'\'''
FATAL: unknown git/gitolite command: 'git receive-pack '/my-repo.git''
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
and
GIT_TRACE=1 git push ssh://git@localhost/my-repo.git master:master
16:53:52.207016 git.c:439 trace: built-in: git push ssh://git@localhost/my-repo.git master:master
16:53:52.207808 run-command.c:663 trace: run_command: unset GIT_PREFIX; ssh git@localhost 'git-receive-pack
'\''/my-repo.git'\'''
Everything up-to-date

So, it is definitely the client.

Then, I had a look at git config in this repo, and got
# git config --list --show-origin | grep receive
file:<user>/.gitconfig remote.origin.receivepack=git receive-pack

I do not know why this was in this user's config, but it was the source of this strange behavior. Removing this line
restored everything back to normal, and I learned about --show-origin ;).

Best,
Daniel
signature.asc

Sitaram Chamarty

unread,
Feb 5, 2020, 8:13:22 PM2/5/20
to Daniel Dietsch, gito...@googlegroups.com
Excellent! (And a big thank you to Tony!)

I did not even know (or I forgot, having never used it) that
such an option existed.

sitaram
> --
> You received this message because you are subscribed to the Google Groups "gitolite" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to gitolite+u...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/gitolite/2a654cfc-ea81-9f26-8338-c9388bd0cee6%40informatik.uni-freiburg.de.



Reply all
Reply to author
Forward
0 new messages