How To Configure Git To Interface With Your GitHub Account
June 1, 2025
This is a tutorial for myself, but maybe you'll find it helpful too. It's one of those things that should be straightforward to do, but I only have to do it so infrequently that I forget it. I'm writing it down here so that in 2028 when I have to do it again, I'll know where to look. Through these means I hope to spare myself much misery and heartache.
- You'll need the
gh
command. It's a background dependency for this functionality. In Arch, this comes from the packagegithub-cli
. Install it.
sudo pacman -S github-cli
- Configure
git
to use the same email and username as your account on GitHub.
git config --global user.email "user@example.com"
git config --global user.name "username"
- Generate an SSH key pair if you don't already have one. You can use your email address as an identifier comment if you'd like.
ssh-keygen -t rsa -b 4096 -C "user@example.com"
If you set a passphrase for this key-pair, you can run the following to mitigate having to enter that password over and over.
eval "$(ssh-agent -s)" # This starts the SSH Agent as a background process.
ssh-add ~/.ssh/id_rsa # This loads your private key into the SSH Agent.
-
Next you need to copy the contents of your public SSH key to GitHub. While logged in, navigate to the settings page, find the section for "SSH and GPG Keys". There, select "New SSH Key". For the new key, paste the contents of
id_rsa.pub
. -
Once these settings have percolated, which should happen almost instantaneously, you can use a command like
ssh -T git@github.com
to test if things are working correctly. Output should be something like "Hi username! You've successfully authenticated, but GitHub does not provide shell access."
Now, you should be able to interface with your GitHub account via the git
command.
Comments
(Comments must be approved by a moderator.)
No comments yet. Be the first to leave a comment!