libgit2 / libgit2sharp

Git + .NET = ❤
http://libgit2.github.com
MIT License
3.11k stars 876 forks source link

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

Open belkhir-aziz opened 10 months ago

belkhir-aziz commented 10 months ago

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 '*'

maw136 commented 9 months ago

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.

BastianKamp commented 8 months ago

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.

AlexSchNev commented 7 months ago

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 '*'