.net - C# Git Command issue -


i developing app need run git command c#. used process run commands if passing user name , password says username or password incorrect actual working conventional. below code:-

public static void pullcode(string gitcommand) {     string strpassword = "password";     processstartinfo gitinfo = new processstartinfo();     process gitprocess = new process();      gitinfo.createnowindow = true;     gitinfo.username = "username";     gitinfo.password = misc.convertpassword(strpassword);     gitinfo.useshellexecute = false;     gitinfo.filename = @"c:\program files (x86)\git\bin\git.exe";  //git repostory directory path     gitinfo.arguments = gitcommand; //git command such "fetch orign"     gitinfo.workingdirectory = @"e:\code demo\testrepo";  //your_git_repository_path want copy data     gitinfo.redirectstandarderror = true;     gitinfo.redirectstandardoutput = true;      using( var proc = new system.diagnostics.process() )     {         proc.startinfo = gitinfo;         proc.start();          var output = proc.standardoutput.readtoend();         var error = proc.standarderror.readtoend();          var lograw = string.isnullorempty( output ) && !string.isnullorempty( error )             ? error.split( '\n' ).toarray()             : output.split( '\n' ).toarray();          proc.waitforexit();         proc.close();     } } 

you have 2 options. first 1 set configuration git repo (or globally) use git askpass witch "git config core.askpass git-gui--askpass". call first command process. drawback here each time modifying command ask password.

or can have own executable witch ask password once, , have option store password application. here have careful since if don't store security risk.


Comments

Popular posts from this blog

node.js - Mongoose: Cast to ObjectId failed for value on newly created object after setting the value -

[C++][SFML 2.2] Strange Performance Issues - Moving Mouse Lowers CPU Usage -

ios - Possible to get UIButton sizeThatFits to work? -