gitgithub

Sign Github commit with ssh key for specifics folders only (Verified badge)


Verified badge github

I am trying to get the "Verified" badge on my GitHub commits, but only for repositories located in a specific folder.

On my work computer, I have some personal GitHub repositories and work repositories (private GitLab).

I want to configure Git conditionally based on the folder where the repository is stored, so I don't have to manually set the Git configuration for each repository.

For example


Solution

  • After searching, here is a quick way:

    1. Generate a private/public key

    ssh-keygen -t rsa -f ~/.ssh/github_id_rsa
    

    2. Add you public key as "signed key" on your github account

    sshkey on github account

    3. Update your .gitconfig

    ~/.gitconfig

    [user]
        name = John Doe
        email = john@company.com # Your work email 
        
    [includeIf "gitdir:~/perso/"]
        path = ~/.gitconfig-github
        
    # Rest of your configuration...
    

    ~/.gitconfig-github

    [user]
        name = UsernameGithub
        email = 000000+user@users.noreply.github.com # your github email
        signingkey = ~/.ssh/github_id_rsa.pub
        
    [gpg]
        format = ssh
    [commit]
        gpgsign = true