How to git push from VSTS build


When I run a git push from my VSTS build the push works but my build fails.


Use the –q switch on your git push command.


By default the PowerShell and Command Line tasks in VSTS will fail if anything is written to standard error which makes perfect sense. 

Well it does until a tool writes status messages on standard error.

The line starting with “To https://” is the one causing all the issues. It is not an error but being written to standard error which causes the build to fail.

Luckily, we can use the –q switch to have it only write real errors to standard error and get the desired results.

Now when I run my build the build succeeds.

I also tested that if something bad really happened the build does fail as expected.

Comments (4) -

  • Matt

    10/19/2017 7:20:08 PM | Reply

    This was really helpful and it got me unstuck from one problem, and onto a new problem! Which is this: I want to push to my remote git repo from a VSTS build, but I can't figure out how to authenticate to it (except by putting the credentials right in the command line, which is terrible). It's the same source I use for the build (a BitBucket repo). The only info I can find on pushing to a git remote in a VSTS build doesn't address how to handle authentication properly. Any guidance? My command line step is currently failing because when I try to push, it wants to prompt for username/password input from the command line.

  • jeff przylucki

    11/9/2018 10:04:58 PM | Reply

    I am running an on-prem TFS and Build Agent machine, and I am attempting to git push to a tfs git repo... the task just hangs.. I think it might be waiting for credentials.. So I installed the Git Credential Manager for Windows ( and run the commands to try to force non-interactive prompting:
    git config --global credential.interactive never
    git config --global credential.authority NTLM

    but still my git push step just hangs...  any thoughts/help/direction?

    • Haar

      3/11/2019 8:53:56 AM | Reply

      @jeff przylucki, did you get any solution. I am also stuck with the "git push".

  • Nagasesha

    5/22/2019 1:13:48 AM | Reply

    use full git exe path like C:\Program Files\Git\cmd\git.exe  
    push origin master -q

Add comment