Multiple git accounts missing username and email

71 views Asked by At

I have work and personal repos and want to switch between the two on the same machine with their respective git accounts. I have set up GPG Signed commits on the work repo and I want to set up ssh commits on a personal repo and be able to switch between the two.

But I keep getting this error

Author identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "[email protected]"
  git config --global user.name "Your Name"

I have a folder structure like so:

root
  |_ .gitconfig
  |_ .ssh 
      |_config
      |_mypersonal (ssh key)
      |_mypersonal.pub (ssh key)
  |_ Desktop
        |_ repos (work)
             |_ .gitconfig.work
             |_ workRepos...
        |_ myrepos (personal)
             |_ .gitconfig.pers
             |_ personalRepos...

And these are the git files listed above:

# .gitconfig

[includeIf "gitdir:~/Desktop/myrepos/"]
path = ~/Desktop/myrepos/.gitconfig-pers

[includeIf "gitdir:~/Desktop/repos/"]
path = ~/Desktop/repos/.gitconfig-work

[core]
excludesfile = ~/.gitignore
#config

Host *
  AddKeysToAgent yes
  UseKeychain yes
  IdentityFile ~/.ssh/mypersonal
#.gitconfig.work

[user]
        email = [email protected]
        name = Me Work
        signingkey = *********************************
[commit]
        gpgsign = true
#.gitconfig.pers

[user]
email = [email protected]
name = Me Personal

[github]
user = “githubUserName”

[core]
sshCommand = “ssh -i ~/.ssh/mypersonal”
1

There are 1 answers

0
VonC On BEST ANSWER

Double-check the path declared in your global config, and use:

git config --list --show-origin --show-scope

In each repository.

You can compare your setup with the process described in this gist.


As the OP C0deJack mentions in the comments:

  • The file name should be .gitconfig-pers
  • The double quotes should be " rather than