Git
Git is a widely-used, open-source tool for managing versions of a project.
Configuration
Shell Aliases
Add these aliases to your .bashrc or .zshrc to make life easier:
# Git
alias clone="git clone"
alias checkout="git checkout"
alias update="git fetch && git pull"
alias push="git push"
alias commit="git commit -a"
alias add="git add"
alias pull="git pull"
alias status="git status"
alias log="git log --all --decorate --oneline --graph"
alias cherry-pick="git cherry-pick"
export GITHUB_TOKEN="<YOUR_GITHUB_ACCESS_TOKEN>"
export PAT=$GITHUB_TOKEN
Set Global Git User Name/Email
git config --global user.name "FIRST_NAME LAST_NAME"
git config --global user.email "MY_NAME@example.com"
Git Commit Signing
This section describes how to create an SSH key, and configure Git to use it to sign commits.
First, generate a new SSH key:
ssh-keygen \
-t ed25519 \
-C "cacarlson@nvidia.com" \
-f "${HOME}/.ssh/id_ed25519_nvidia_git_signing" \
-P ""
Upload the .pub signing key to GitHub: https://github.com/settings/keys
Choose New SSH Key, set the title to something descriptive i.e., "Nvidia MacBook Signing Key",
then choose Key Type: Signing Key, and copy/paste the contents of the ${HOME}/.ssh/id_ed25519_nvidia_git_signing.pub
into the Key field. You’ll need to authenticate with 2FA to add this to your account.
Now, make Git aware of it. This sets the options globally, but you can remove the --global flag and
just run these commands in your repo directory to set the Git config options for that repo.
git config --global user.name "Caleb Carlson"
git config --global user.email "cacarlson@nvidia.com"
git config --global user.signingkey "~/.ssh/id_ed25519_nvidia_git_signing.pub"
git config --global gpg.format ssh
git config --global commit.gpgsign true
Next, we need to create an allowed signers file. This is a file containing ssh public keys which you are willing to trust.
mkdir -p ~/.config/git
echo "cacarlson@nvidia.com $(cat ~/.ssh/id_ed25519_nvidia_git_signing.pub)" > ~/.config/git/allowed-signers
git config --global gpg.ssh.allowedSignersFile ~/.config/git/allowed-signers
From now on, when you git commit, you can do it like this: git commit -a -s -S, and it will sign your commit
using the signing key you configured.
Then, you can view your new commit via git log --show-signature:
commit a45186c94b76fc605b73ff93c93a7882420e1da2 (HEAD -> master)
Good "git" signature for cacarlson@nvidia.com with ED25519 key SHA256:mWy0S6deDF8dXu13zQXvnhnrA/BGEl6i6kuABEq2A6c
Author: Caleb Carlson <cacarlson@nvidia.com>
Date: Tue Apr 21 09:46:37 2026 -0600
Add git signing docs, pt. 1
Signed-off-by: Caleb Carlson <cacarlson@nvidia.com>
Commands
Useful git commands for managing a repository.
Sign-off on a Commit
| This is different from signing a commit. |
Commit messages should be formatted with the first name, last name, and email address associated with GitHub for that repository.
Commit message.
first_name last_name <email_address>
For example,
Generate vendor dependencies at build-time
* Remove vendor/ directory
* Generate vendor/ during build
* Gitignore vendor/ dir
* Add go mod vendor to make build
* Add go mod vendor to docker build
* Use go mod download instead of vendor
Signed-off-by: Caleb Carlson <ccarlson355@gmail.com>
Delete a Branch
Delete a local branch:
git branch --delete <branchname>
| Make sure you switch to another branch before doing this so you’re not stranded on a deleted branch. |
Example:
➜ hpc-sp-kjplat-img git:(bugfix/SSM-4489) ✗ checkout master
Switched to branch 'master'
Your branch is up to date with 'origin/master'.
➜ hpc-sp-kjplat-img git:(master) ✗ git branch --delete bugfix/SSM-4489
warning: deleting branch 'bugfix/SSM-4489' that has been merged to
'refs/remotes/origin/bugfix/SSM-4489', but not yet merged to HEAD.
Deleted branch bugfix/SSM-4489 (was 8d7abea).
Delete the remote branch:
git push origin --delete <branchname>
Example:
➜ hpc-sp-kjplat-img git:(master) ✗ git push origin --delete kjplat-634
To github.hpe.com:hpe/hpc-sp-kjplat-img.git
- [deleted] kjplat-634
You can also use the GitHub repository web UI to delete the remote branch.
Push Repo to New Upstream
If you’ve cloned out a repo from one source, like GitLab, and would like to push it to a blank GitHub repo,
you can do so easily by adding an upstream remote to your Git workflow.
-
Add an upstream
git remote add upstream git@github.com:inf0rmatiker/antora-site-ui.git -
Push your master or main branch to your new upstream
git push upstream master