Aral Balkan

Mastodon icon RSS feed icon P2P network icon

Initial git configuration

I’m setting up my new XPS 13 running Pop!_OS and one of the things I always have to do on any new machine is to configure git.

So, both for my own reference and in case it helps anyone else, here’s a list of things I do to set up git:

Set up my identity (used in commits, tags, etc.)

git config --global user.name "Aral Balkan"
git config --global user.email mail@ar.al

Set up automatic signing of my commits

I sign my work and so should you (it’s about security, not vanity).

  1. Either generate GPG keys if you don’t already have a pair or export/import your existing GPG keys.

  2. Configure git to sign all your work:

    git config --global commit.gpgsign true

You can check that it’s working by making a commit and then viewing at it in the log with the --show-signature flag:

git log -1 --show-signature

If you get a warning along the lines of WARNING: This key is not certified with a trusted signature! There is no indication that the signature belongs to the owner after importing your GPG key to a new machine, do the following (substituting your email address for mine):

gpg --edit-key aral@ind.ie

Then, in the gpg shell, use the trust command and select 5 = I trust ultimately.

Screenshot of terminal showing the result of the commands issued in the instructions above.

If you don't trust yourself, who are you going to trust?

Create ssh keys for the machine and import them into hosted git remotes like GitLab

In order to clone and push to git remotes using ssh, you have to create an ssh keypair and then upload it to your git remote (in my case, we use our own GitLab instance running on source.ind.ie).

  1. Generate your ssh keys (substitute your email address for mine):

    ssh-keygen -t rsa -C "aral@ind.ie" -b 4096
  2. Copy it onto the system clipboard.

    cat ~/.ssh/id_rsa.pub | pbcopy

Note: On Linux, you can simulate the hugely useful pbcopy and pbpaste commands on macOS by adding the following to your .zshrc or .bashrc files:

alias pbcopy='xsel --clipboard --input'
alias pbpaste='xsel --clipboard --output'

Disable paging

Set cat as the pager so that git commands do not use paging (I’d much rather scroll than switch modes.)

git config --global core.pager cat

That’s all I can think off at the moment. If I notice that I’ve left anything off, I’ll update the post accordingly.

If you have any initial configuration steps that you cannot live without, please let me know on Mastodon.

References