Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Unable to add .md file using git command Programmatically using C#

Ajay kumar
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
February 21, 2024

Hi Team,

I have integrated bitbucket in our application and I am trying to add a folder that contains approx. 400+ .md files using git command (add *) programmatically using C# code, but these files remains untracked. It works fine for .txt and .json files.

Below is the sample code  :

bitbucketService.ExecuteGitWindowsCommand(mainDirectory, $"checkout -b {BranchName}");
//Code to copy some extra file and folders that contains .md file in checkout branch.
//Code to add .md files using git command
bitbucketService.ExecuteGitWindowsCommand(mainDirectory, @$"add *");

public string ExecuteGitWindowsCommand(string workingDirectory, string arguments)
string command_result;

Process ps = new Process();
ps.StartInfo.FileName = GitExePath;
ps.StartInfo.UseShellExecute = false;
ps.StartInfo.RedirectStandardOutput = true;
ps.StartInfo.RedirectStandardInput = true;
ps.StartInfo.RedirectStandardError = true;
ps.StartInfo.WorkingDirectory = workingDirectory;
ps.StartInfo.Arguments = arguments;
command_result = ps.StandardOutput.ReadToEnd();
ps = null;

return command_result;

It works fine for .txt and .json files. but if the folder contains more(25+) .md files then it get fail or stuck at code command_result = ps.StandardOutput.ReadToEnd();

Any help would be apricated thanks.

1 answer

1 vote
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 21, 2024

Hey @Ajay kumar 

I'm not a novice in C# but can you try out the below and see if it works

See if it works for 1 *.md file and then check for how many max number of *.md files. 

If the above is working, you may need to perform this operation in batches. 

If any of the above steps are not working, specify the exact file name and try out performing git add

Let me know

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events