1

I ran into a problem where I have made edits to a repository(org repo) and committed them with my personal git account accidentally. As a result, the commit history on the repo shows that the Committed & Authored identities are from the personal account rather than the official account. Are there any plugins or validation that can be enforced for each repo before committing the changes?

Or is there any efficient way to manage multiple git hub accounts?

I am on windows and using VS Code as IDE.

rioV8
  • 24,506
  • 3
  • 32
  • 49
Harish
  • 85
  • 14

1 Answers1

1

I always prefer to use (as documented here):

git config --global user.useConfigOnly true

That way, I am forced to set the right user.name/email on each new local Git repository, in the local Git configuration of the specific repository.

Any tool manipulating the repository (like VSCode making new commits) would then benefit from the right user.

The OP Bugata also mentions in the comments the extension "Git-Identity switcher"

I am able to view the Author while editing itself.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Does this even apply if I am using a repo with Visual Studio rather than VSCode? – Harish Feb 11 '21 at 09:27
  • @Bugata Yes, both VSCode or Visual Studio would read and take into account a git local configuration. And if that local configuration has the right information in it, you won't have any issue! – VonC Feb 11 '21 at 09:32
  • In addition to this configuration, with this extension [link](https://marketplace.visualstudio.com/items?itemName=stephtr.git-identity&ssr=false#overview), I am able to view the Author while editing itself. – Harish Feb 11 '21 at 13:13
  • @Bugata Good point. I have included your comment in the answer for more visibility. – VonC Feb 11 '21 at 13:18