git-autoconfig
git-autoconfig copied to clipboard
git-autoconfig: Failed to get git repository root.undefined
What can cause this error message? I just installed the plugin and I am trying to 'set' the config.
In my workspace I have numerous folders containing .git folders in them so I don't know where I can define the repository.root
Make sure you open the folder path directly rather than a folder in a workspace.
Make sure you open the folder path directly rather than a folder in a workspace.
What do you mean by this? I have the folder expanded in the workspace and have ran git init and can see the .git folder, but I get the same error when trying to set local config.
Hi, I must have come across the same error and by the looks of it, just opening that one folder in VSCode (not multiple folders in the workspace) which seemed to fix the issue. However, since it's been over a year, (and didn't realise there were 4 confused faces!), I can't remember more about the error unfortunatly.
However, if it helps and you are happy to use access keys instead, you can embed the access key into your local git folder which allows you to use different credentials for each folder, without using git-autoconfig:
CD D:\GIT[LOCAL FOLDER] git remote set-url origin https://[USERNAME HERE]:[ACCESS KEY HERE]@github.com/[Repo HERE]/[REPO NAME].git git config --global credential.helper store
I've been doing this for over a year now. Hope this helps.
That only works for Github though. What about other repos, e.g. Azure DevOps?
And if you're going to modify the .local config, you might as well just manually add the user config in there, which is basically what git-autoconfig is doing. If you add it manually, the issue is fixed.
Seems like valid points. I didn't find much benefit for git-autoconfig for me personally, I was happy to add it in manually in the end, but didn't know how to do that at the time. Hopefully my contribution might help some wanderer.
Or just use alias. In your global gitconfig (located under C:\Users\username.gitconfig), add this block to the very top:
[alias]
GitHub-Personal = !git config --global user.name 'Personal GitHub' && git config --global user.email [email protected]
GitHub-Work = !git config --global user.name 'Work GitHub' && git config --global user.email [email protected]
then just run:
git github-personal
or
git github-work
and it'll switch aliases to use the correct account context. Since this is defined in the global git config, you only need to configure it just once and in any of your projects, you can switch configs easily using the command above. You don't need to even set a local config or set access key PER project folder.
However, I still much prefer having a local config per folder, it's more granular and gives more control.
Thanks for the input. I think I found when setting the usernames as such, each one required authentication and I seem to remember having a hard time authenticating to both repositories using two different usernames at the same time. It was not seamless as such. Often a folder would refuse to sync where I had to essentially switch the authentication round and that was also confusing. I found this problem went away when I started using the access keys, but nether the less, when I comes across this again, I'm sure to take another look at it. Thanks for contributing to the thread.