In the Git plugin, a  %Studio.SourceControl.Base subclass , I get the active branch
Set Active=##class(Git.Utils).GetActiveBranch(Repos.Directory)
If Active["fatal" {
Set sc=##class(Git.Utils).AddToSaveList(Repos.Name)
}
If that gets a fatal I call:
Set Command="cd "_Repository.Directory_" && git config --global --add safe.directory "_Dir
Set sc=..CPipe(Command,.Output)

This process runs under the Studio account