How to git push from Git for Windows client to git-daemon running on ubuntu

576 Views Asked by At

I want to eventually run a git server on a Raspberry Pi but for now I am testing on ubuntu (running on VirtualBox VM). My development machine is Windows 7 64 bit and running Git For Windows v2.32.0.windows.2 (latest).

I have setup the gitserver on ubuntu like this:

git init --bare myexample.git
git daemon --base-path=. --export-all --enable=receive-pack --reuseaddr --informative-errors --verbos -- ./myexample.git

--enable=receive-pack is supposed to allow push

I have connectivity from Windows to linux, ie I can ping both ways.

I can successfully clone and push from ubuntu:

angus@angus-VirtualBox:~/Documents/Courses/oss/client$ git clone git://192.168.0.92/myexample.git
Cloning into 'myexample'...
warning: You appear to have cloned an empty repository.
angus@angus-VirtualBox:~/Documents/Courses/oss/client$ ls
myexample
angus@angus-VirtualBox:~/Documents/Courses/oss/client$ cd myexample/

I then add a file and commit

angus@angus-VirtualBox:~/Documents/Courses/oss/client/myexample$ git push
Enumerating objects: 3, done.
Counting objects: 100% (3/3), done.
Delta compression using up to 2 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3), 282 bytes | 282.00 KiB/s, done.
Total 3 (delta 0), reused 0 (delta 0)
To git://192.168.0.92/myexample.git
 * [new branch]      master -> master

But when I attempt the same from Windows I get:

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client
$ git clone git://192.168.0.92/myexample.git
Cloning into 'myexample'...
remote: Enumerating objects: 3, done.
remote: Counting objects: 100% (3/3), done.
remote: Compressing objects: 100% (2/2), done.
remote: Total 3 (delta 0), reused 0 (delta 0)
Receiving objects: 100% (3/3), done.

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client
$ cd myexample/

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client/myexample (master)
$ git add .

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client/myexample (master)
$ git commit
[master 9099126] changed hello world to hi guys
 1 file changed, 1 insertion(+), 1 deletion(-)

angus@Angus-PC MINGW64 /d/projects/Coursera/open-source-software-development/gitstuff/client/myexample (master)
$ git push

It just hangs there on git push command.

I also tried:

$ git remote -v
origin  git://192.168.0.92/myexample.git (fetch)
origin  git://192.168.0.92/myexample.git (push)

I did find this page which indicates a bug in msysgit but that dates from 2011.

https://serverfault.com/questions/142048/git-daemon-on-linux

It would be really nice to be able to get this to work. I don't need the security of ssh so just using the git protocol on a protected lan is fine for me.

Running in Windows cmd.exe does appear to go further, but still hangs:

D:\projects\Coursera\open-source-software-development\gitstuff\client\myexample>git push
Enumerating objects: 5, done.
Counting objects: 100% (5/5), done.
Delta compression using up to 8 threads
Compressing objects: 100% (2/2), done.
Writing objects: 100% (3/3)

So it looks like it gets further - but if I check on server end, no change to repo.

2

There are 2 best solutions below

0
On

I have encountered the very same situation described above. I am running Virtual Box 6.1.32 on a Windows 10 box with an Ubuntu (16.04.7) installation as guest system inside. On the Windows host I am working with git for windows (version 2.33.0.windows.2) and TortoiseGit 2.13.0.1. The git version 2.7.4 is used on the Linux side of things. The following "tweak" enabled me to push commits into the Linux system: i) Open the configuration file with the global git settings (TortoiseGit Context Menu -> Settings -> Git, then press the button "Edit global .gitconfig") for the host or use a text editor and find this file inside Your Windows "Home" folder. ii) Add the following lines to the global configuration file:

[sendpack]
  sideband = false

I found this tweak here: http://billauer.co.il/blog/2012/10/git-pull-windows-freeze-receive-pack/ by pure luck and was very surprised that it is still relevant today.

0
On

The problem seems to be with the sideband implementation in git for windows, which doesn't play well with pushing to git-daemon for some reason.

You can work around this by disabling the sideband locally in your repo - do no disable it globally unless all your repositories exclusively interact with git-daemon remotes, to keep the ability to efficiently interact with Github and the like.

This command will disable the sideband in your current repo:

git config –-local sendpack.sideband false