Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8687801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T23:12:02+00:00 2026-06-12T23:12:02+00:00

I want to run git commands from c#. below is the coded I had

  • 0

I want to run git commands from c#. below is the coded I had written and it does execute the git command but I am not able to capture the return value. When I manually run it from command line this is the output I get.

enter image description here

When I run from the program the only thing I get is

Cloning into 'testrep'...

Rest of the info is not capture, but the command is executed successfully.

class Program
{
    static void Main(string[] args)
    {
        ProcessStartInfo startInfo = new ProcessStartInfo("git.exe");

        startInfo.UseShellExecute = false;
        startInfo.WorkingDirectory = @"D:\testrep";
        startInfo.RedirectStandardInput = true;
        startInfo.RedirectStandardOutput = true;
        startInfo.Arguments = "clone http://tk1:tk1@localhost/testrep.git";

        Process process = new Process();
        process.StartInfo = startInfo;
        process.Start();

        List<string> output = new List<string>();
        string lineVal = process.StandardOutput.ReadLine();

        while (lineVal != null)
        {

            output.Add(lineVal);
            lineVal = process.StandardOutput.ReadLine();

        }

        int val = output.Count();
        process.WaitForExit();

    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T23:12:03+00:00Added an answer on June 12, 2026 at 11:12 pm

    From the manual page for git clone:

    –progress
    Progress status is reported on the standard error stream by default when it is attached to
    a terminal, unless -q is specified. This flag forces progress status even if the standard
    error stream is not directed to a terminal.

    The last three lines in the output when running git clone interactively are sent to standard error, not standard output. They won’t show up there when you run the command from your program, however, since it’s not an interactive terminal. You could force them to appear, but the output isn’t going to be anything usable for a program to parse (lots of \rs to update the progress values).

    You are better off not parsing the string output at all, but looking at the integer return value of git clone. If it’s nonzero, you had an error (and there will probably be something in standard error that you can show to your user).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to remove all files from Git at ~/bin/. I run git rm
I want my ASP.NET page to shell out and execute git commands. I put
How would I run git commands on a repo when I have not cd
Currently I want to run a batch file that fires the command git log
Sometimes I want to be able to pull from a repo (via clone). But
I want run all script from the directory . Like , The directory contains
I have written php program and uploaded on server. I want run this program
Want to run javascript function from parent window in child window Example I have
So I've installed msysgit, and run git successfuly from the bash shell. From within
I want to run few commands when i start application on server. So, i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.