Skip to content

Git Configuration⚓︎

Git is a version control system. It is used to track changes in source code.

:fontawesome-brands-git-square: Install Git and helper tools⚓︎

sudo apt install git

Git extras is a collection of tools that help with git.

sudo apt install git-extras

Install diff-so-fancy to make git diffs look pretty.

Install GitHub CLI⚓︎

Github CLI is a command line interface for using GitHub.

curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
sudo apt update
sudo apt install gh

Install Gitkraken (Optional)⚓︎

Gitkraken is a GUI for git.

Setup Git and GitHub⚓︎

Setup Git credentials⚓︎

git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"
# Confirm that you have set the Git username correctly:
git config --global user.name # Should output => "Your Name"

# Confirm that you have set the Git email correctly:
git config --global user.email # Should output => "your_email@example.com"

Reference: https://docs.github.com/en/get-started/quickstart/set-up-git

Setup GitHub credentials⚓︎

Check if you are logged in to GitHub:

gh auth status

If not, login with:

# Login and select options manually as prompted
gh auth login

# Login with pre-selected options (recommended)
gh auth login -h github.com -p ssh -w

# If you want to request additional scopes while authenticating,
# you can request them with -s flag
# For example, to request the `workflow` scope, you can use:
gh auth login -h github.com -p ssh -s workflow -w

Configure Git to use GitHub CLI as credential helper

gh auth setup-git

See:

Sample .gitconfig⚓︎

View your git config:

git config --global --list

OR

cat ~/.gitconfig

Your .gitconfig file should look like this:

[user]
    email = <your-email>
    name = <your-name>
    signingkey = <your-key>
[filter "lfs"]
    clean = git-lfs clean -- %f
    smudge = git-lfs smudge -- %f
    process = git-lfs filter-process
    required = true
[commit]
    gpgSign = true
[credential]
    helper = /usr/lib/git-core/git-credential-libsecret
[core]
    pager = diff-so-fancy | less --tabs=4 -RFX
[color]
    ui = true
[color "diff-highlight"]
    oldNormal = red bold
    oldHighlight = red bold 52
    newNormal = green bold
    newHighlight = green bold 22
[color "diff"]
    meta = 11
    frag = magenta bold
    commit = yellow bold
    old = red bold
    new = green bold
    whitespace = red reverse
[credential "https://github.com"]
    helper = 
    helper = !/usr/bin/gh auth git-credential
[init]
    defaultBranch = main
[credential "https://gist.github.com"]
    helper = 
    helper = !/usr/bin/gh auth git-credential