Use different commit email for different repo's in the same GitKraken profile

Viewed 196

I know I can configure multiple GitKraken profiles and have different commit name/email that way.

But I want to see all my repo's in the same profile, while keeping different name/email per repo.

Is that possible?

(NB: per-repo commit credentials are possible with the git command-line client, of course)

2 Answers

I have spoken to people that work at AXOSoft, the developers of GitKraken, and they currently only support per profile level author (what git calls the name/email combo) so they currently suggest creating a separate profile with the name/email you want. Although I do recall it being asked in their Slack server to have the ability to set a default profile per repo so that when you open a repo it automatically switches profiles. You might want to either join that Slack server or email feedback@gitkraken.com and let them know of your interest for that feature request.

Using different identities in every Git repo inside GitKraken

  • It's not obvious how to assign different names and email addresses for your commits in different Git repos. If you look at GitKraken's GUI, it may look like you are stuck with GitKraken's "current profile" details (name and email).
  • However, that profile is just what GitKraken stores in your global/default ~/.gitconfig file. It's what will be used if a more specific per-project/folder-hierarchy Git config can't be found.
  • To assign a custom name/email per-project, you simply have to assign custom names/emails for Git itself at those paths. GitKraken will always respect Git's settings.
  • First, open a Terminal in the top-level folder of your Git repo. The easiest way to do that is to simply click on the "Terminal" button in GitKraken's GUI.
  • Now run the following two commands to check what name and email your repo is currently using.
git config user.name
git config user.email
  • To update them, simply run any of the commands below with your preferred details. The changes will be saved inside the repository you are editing and will only apply to that repository.
git config user.name "Your Great Name"
git config user.email "your@greatemail.com"
  • Any commits you perform in that repo via GitKraken will now use the new name and email that you have configured.
  • If you want to apply the settings in a wider way, such as for a whole folder where you store all of your GitHub repos, and you want to use the same GitHub identity for all sub-directories there, then you can use Git's includeIf functionality in your global ~/.gitconfig. With that feature, you can tell Git that it should load an additional "gitconfig" file (where you can store a different user identity) if a repo is within a certain path.
  • Here's an example of such a setup. First, edit your global ~/.gitconfig file and add the following section at the bottom. You can add as many of these sections as you want. Just ensure that they appear at the end, after everything else (so that they will be allowed to override all preceding global options). You should read Git's documentation if you want more details about how includeIf works.
[includeIf "gitdir:~/Code/GitHub/YourGreatGitHubName/"]
    path = ~/Code/GitHub/YourGreatGitHubName/gitconfig.inc
  • NOTE: The "gitdir" directive means that any project's .git directories anywhere under that path will first be reading the global config (at ~/.gitconfig) as usual, and then they'll include their own custom config for that entire directory tree (thanks to the includeIf directive that we added), and finally they'll load the project's own .git/config file (which has ultimate control of the settings and can further override the name/email for that specific project, which is what was described earlier in this guide with the git config commands).
  • Next, create the gitconfig.inc file that you pointed at (in the path location). Insert your custom name and email in that configuration file, using the same format as this example.
[user]
    name = Your Great Name
    email = your@greatemail.com
  • Now all projects under that path will automatically use those details, and you can still override their git config user.* details on a per-repo basis if required, as described earlier.
Related