H.Scheidl
H.Scheidl

Reputation: 845

How to configure multiple git accounts in Visual Studio Code workspace

When switching between code-bases stored in different git repositories from different servers (for example Bitbucket and Github), I have sometimes committed code using the wrong user name.

Using Visual Studio Code, is there a way to set the values for user.name which are saved for a folder or workspace?

Upvotes: 16

Views: 10105

Answers (1)

albertopasqualetto
albertopasqualetto

Reputation: 107

Here are some ways to achieve your result.

Git local config files

Open a terminal in the repo folder and use the commands:

  • git config --local user.name "FIRST_NAME LAST_NAME"
  • git config --local user.email "[email protected]"

Your new configs will appear in the file <REPO_FOLDER>/.git/config.

Now VSCode will override your global settings with the local ones.

Source: https://git-scm.com/docs/git-config

VSCode extensions

Otherways, if you want to directly modify the profile from inside VSCode these are 2 extensions which may help you:

Scheduling idea

Another idea could be running a script from taskschd.msc every X time which checks all folders inside /Github or /Gitlab and assigns the relative profile to the config file.

Upvotes: 6

Related Questions