1

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 "you@example.com"
  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 = mywork@email.com
        name = Me Work
        signingkey = *********************************
[commit]
        gpgsign = true
#.gitconfig.pers

[user]
email = mypersonal@email.com
name = Me Personal

[github]
user = “githubUserName”

[core]
sshCommand = “ssh -i ~/.ssh/mypersonal”
C0deJack
  • 143
  • 1
  • 10
  • 1
    Run `git config --list --show-origin` to see what's actually set. It seems like these are wrong: `.gitconfig-pers`, for instance, vs the file's name being `.gitconfig.pers` (note that one has one dot and one hyphen and the other has two dots and no hyphen). – torek May 17 '22 at 17:39
  • Thanks Torek. Yes it was a combination of two things: The file name you spotted didn't match `.gitconfig-pers` and also I copied the contents of some of the file from a tutorial and zsh didn't like the double quotes. They should of been `"` rather than `”` – C0deJack May 18 '22 at 09:14

1 Answers1

1

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
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250