GitCloneTask doesn't clone repository (“The remote end hung up unexpectedly”)

i’m trying to write a buildfile with phing and the GitCloneTask (to clone a repo from github), but i keep getting this message everytime i run phing:

The remote end hung up unexpectedly

  • Problems getting my ANT builds to work after OS upgrade
  • Building PhantomJS-2 from source on Windows
  • Configure Jenkins to connect to BitBucket
  • TeamCity triggers too many builds for a new branch
  • How to dynamically pick a git branch to use in Jenkins build
  • How can i add an administrative build in jenkins?
  • So i checked if i could clone the repo with git-clone => works just fine;

    checked my .gitconfig for an error with the Github API Token & Username => no typos or something

    checked all repo-urls provided on github (ssh, https, read-only) => none of them changes the message when used in the buildfile

    any ideas?

    here’s the code of the buildfile:

    <?xml version="1.0" encoding="UTF-8"?>
    <project name="ort" default="init">
    <!-- ============================================  -->
    <!-- Target: initialize                            -->
    <!-- ============================================  -->
        <target name="init"> 
            <input propertyname="local.documentRoot">Where to put the files?:</input>
            <mkdir dir="${local.documentRoot}" />
                targetPath="${local.documentRoot}" />

  • How to get database credentials into a c# application without committing it to source code?
  • How to convert a git merger into a rebase
  • How should I structure the files/directories in my Git repository?
  • How to go back to last commit + delete all newly created files?
  • How to rename GIT central repository
  • Capistrano deploy on windows fails with git
  • 3 Solutions collect form web for “GitCloneTask doesn't clone repository (“The remote end hung up unexpectedly”)”

    I did some debugging in the phing class and I think the issue is that you need to specify the path/name of your git binary in the “gitPath” attribute.

    I think on Linux is might be something like “/usr/lib/git”, I’m running windows and simply used “git”

    <target name="gitclone">
        <echo msg="Getting latest code from ${git.repo}" />
        <gitclone gitPath="git" repository="${git.repo}" targetPath="${build.dir}" />

    This worked because my git binary (C:\Program Files\Git\cmd) is in my windows PATH…i.e. I can open a command prompt and type “git” and windows will know where it is.

    Annoyingly I am cloning a private repo which requires me to enter a passphrase as well -_-

    i didn’t figure out why the GitCloneTask doesn’t work as expected, but i solved my resulting problem – no automatic repo-cloning – with a workaround: i didn’t use GitCloneTask, instead i used the execTask:

    Here’s my code:

    <property name="remote.repositoryPath" value="git://" />
    <input propertyname="local.documentRoot">Where to put the files?:</input>
    <exec command="git clone ${remote.repositoryPath} ${local.documentRoot}" />

    Neither an elegant nor the ideal solution, but for now it works…

    In my case I didn’t have permission to clone to the directory I was trying to clone to. I didn’t know this because the error didn’t mention it. Someone has created a patch but it is not merged to the mainline as of this posting.

    Take a look at where the exception is being thrown by running phing with -verbose. In my case it was coming from GitCloneTask.php line 77 which said.

    throw new BuildException('The remote end hung up unexpectedly');

    I modified this to include the root cause.

    throw new BuildException('The remote end hung up unexpectedly', $e);

    And I now get:

    fatal: could not create work tree dir 'your-repo'.: Permission denied

    Fixed permissions and it now works fine.

    Git Baby is a git and github fan, let's start git clone.