Skip to main content

Command Palette

Search for a command to run...

Git inside distrobox

Updated
2 min read
Git inside distrobox

I ran this command from inside a distrobox. Because of old habits I installed git inside the distrobox. This message made me wonder how to approach this situtaion. Should I config everything in the host machine and have it somehow transfered to the distrobox when needed? Or let go with doing git inside distroboxes?

Because Distrobox mounts the host's $HOME, running git config --global modifies the single, shared ~/.gitconfig file used by both the container and the host.

Ok, cool. We can move on as if we were on the same machine. What about SSH keys?

Well, we already know that the whole $HOME is passed on, so the keys at ~/.ssh are also available to the distrobox. It seems that we need to ensure that the host’s ssh-agent is running then:

Distrobox typically passes required variables automatically, including $SSH_AUTH_SOCK, when you use the distrobox enter command.

I could also write yet another post on how to deal with keys but these links below will help:

OK! I created a key and will try to use it inside a distrobox now.

It just works! Out of the box, well, in this case… anyways. I only had to answer yes to add github.com to my knowhosts file and is working. Time for me to go back to the parent article of this one.

Ops, forgot to add some important configuration. For the user.name I use the same from github.com but I believe you can use anything you want. And for the user.email I recommend enabling the private email option on github.com settings page(see below) and use that @users.noreply.github.com email they provide.

git config --global user.name "aviler" && git config --global user.email "399399+aviler@users.noreply.github.com"