Title: How to call git-fetch from Visual Studio Extension?
Tags: visual-studio;visual-studio-2017;visual-studio-extensions;vs-extensibility
Question: I'm developing custom VS extension that will add some more UI to git source control plugin in Visual Studio. The UI is done.
Is there some API in Visual Studio SDK that I can use to invoke git related commands (git fetch for example) or to retrieve git related settings, e.g repository url?

Here is the accepted answer: You could call git command through C# code with Process. Please refer to following sample code.
string gitCommand = "git";
string gitAddArgument = @"add -A" ;
string gitCommitArgument = @"commit ""explanations_of_changes"" "
string gitPushArgument = @"push our_remote"
Process.Start(gitCommand, gitAddArgument );
Process.Start(gitCommand, gitCommitArgument );
Process.Start(gitCommand, gitPushArgument );
And you also could try use LibGit2Sharp NuGet package which is a native Git implementation. About how to use it in C#, please refer to below blog.
http://blog.somewhatabstract.com/2015/06/22/getting-information-about-your-git-repository-with-c/
Comment for this answer: I don't found such fucntions in Visual Studio APIs (https://msdn.microsoft.com/en-us/library/mt459278.aspx).
Comment for this answer: You could reflect the Team Explorer installer to check whether you could get the method that it calls. You could get the Team Explorer from here: https://www.visualstudio.com/thank-you-downloading-visual-studio/?sku=TeamExplorer&rel=15 and this blog introduce how to reflect a .exe file: https://blogs.msdn.microsoft.com/csharpening/2007/12/19/using-reflection-to-automate-testing-of-an-exe-file/
Comment for this answer: Yes, I'm doing exactly this. However, when I install Visual Studio is a git.exe known command? I've always tought that Visual Studio uses some internal git executable by default
Comment for this answer: I would like to see source codes of Team Explorer. Any plans to open source it? :)
Comment for this answer: The installer probably isn't .NET assembly and it is just setup bootstrapper anyway. Maybe you know in what assembly the Git Source Control extension resides...


{'source': 'StackExchangeDataset', 'subset': 'stackoverflow.com', 'metadata': {'AnswerCount': 1, 'CommentCount': 0, 'ContentLicense': 'CC BY-SA 3.0', 'CreationDate': '2017:00:09/21/17', 'FavoriteCount': None, 'PostTypeId': 1, 'Tags': '<visual-studio><visual-studio-2017><visual-studio-extensions><vs-extensibility>', 'Title': 'How to call git-fetch from Visual Studio Extension?', 'ViewCount': 210, 'id': 46347076, 'user_AboutMe': "<p>I've been .NET Developer since Microsoft has sent me DVD with trial version of Visual Studio 2005.</p>\n<p>My first books on JavaScript were WebMaster in a Nutshell and DHTML (2000) in Action (2000).</p>\n<p>I've become professional in 2007.</p>\n", 'user_AccountId': 219060.0, 'user_DisplayName': 'Liero', 'user_Reputation': 23053.0, 'user_Views': 1547.0, 'user_id': 475727.0}}