libgit2sharp icon indicating copy to clipboard operation
libgit2sharp copied to clipboard

[Question] Is there a way to add safe.directory '*' via libgit2

Open belkhir-aziz opened this issue 1 year ago • 4 comments

I want to avoid executing commands and updating files manually. Is there an existing API within libgit2 that replace this command => git config --global --add safe.directory '*'

belkhir-aziz avatar Aug 31 '23 12:08 belkhir-aziz

Hi, Is there an issue with using Repository.Config of Configuration type. Specifically Set<> family of methods? From the top of my head your call would look like: repostiory.Config.Set("save.directory", "*"); Or am I missing something? Be advised that I haven't used the library yet and I am just getting familiar with the API - hoping to use it in a following months.

maw136 avatar Oct 05 '23 14:10 maw136

Hi, Is there an issue with using Repository.Config of Configuration type. Specifically Set<> family of methods? From the top of my head your call would look like: repostiory.Config.Set("save.directory", "*"); Or am I missing something? Be advised that I haven't used the library yet and I am just getting familiar with the API - hoping to use it in a following months.

Yes. I get the error "repository path .... is not owned by current user" when i try to create the repository with: new Repository(workRepoPath)

That is the reason why i want to add the save directory option.

BastianKamp avatar Oct 24 '23 13:10 BastianKamp

Hi, you would need any local repository, which you can access, and create a configuration for this one. With this configuration instance, you are able to change global settings. For Example, if you have an existing local repository under LocalPath, then you could do the following: Configuration.BuildFrom(LocalPath).Add("safe.directory", "*", ConfigurationLevel.Global) This would set the same global configuration value as: git config --global --add safe.directory '*'

AlexSchNev avatar Dec 08 '23 11:12 AlexSchNev