![]() ![]() Note: here I use gitlab to name my identity, but from your question it can be anything, ex: gitolite or github, work, etc. Also repeat this for each identity you want to add: $ gpg -list-secret-keys -keyid-format LONG Ĭopy the public key block and add it to your GitHub/GitProviderOfChoice settings as a GPG key.Īdd identity to Git config. The 8A5C011E4CE081A5 part after sec rsa4096/ is the identifier of key. Note: here is the identifier of created secret key.Įxample here: sec rsa4096/8A5C011E4CE081A5 Repeat next steps for each identities you want to use. $ git config -global -unset user.signingkeyįorce identity configuration on each new local repository: $ git config -global eConfigOnly trueĬreate Git alias for identity command, we will use later: $ git config -global alias.identity '! git config user.name "$(git config user.$1.name)" git config user.email "$(git config user.$1.email)" git config user.signingkey "$(git config user.$1.signingkey)" :'Ĭreate an identity with GPG (use gpg or gpg2 depending on what you got on your system). Unset current user config in git: $ git config -global -unset user.name The fact that he apply and force the identity to each repository created/cloned is a good way not to forget to set this up each time. I very like the way of Micah Henning in his article (see Setting Up Git Identities) on this subject. To use Git 2.13 you will either need to add a PPA (Ubuntu older than 18.04/Debian) or download the binaries and install (Windows/other Linux). Path = ~/.gitconfig.github # user.name and user.email for GitHub Path = ~/.gitconfig.gitlab # user.name and user.email for GitLab ![]() Path = ~/.gitconfig.azure # user.name and user.email for Azure ![]() # The trailing / is VERY important, git won't apply the config to subdirectories without it # If using multiple identities can use per path user/email Path = ~/.faultusername # can maybe leave values unset/empty to get warned if a below path didn't match Path = ~/.gitconfig.alias # I like to keep global aliases separate Since a new enough Git comes with Ubuntu 18.04 I've been using this in my ~/.gitconfig quite happily. As of Git 2.13 you can use an includeIf in your gitconfig to include a file with a different configuration based on the path of the repository where you are running your git commands. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |