Setting up a new git profile shouldn't take more than seconds. This simple, interactive bash utility script automates the process of creating a new git "profile" with its own SSH keys and GPG signing key (optional).
- Creates a new directory structure with .ssh keys
- Generates SSH key pair (using default
ssh-keygensettings) - (Optional) Generates GPG signing key and configures git to use it for signing commits
- Creates a profile-specific
.gitconfigfile in the profile directory - Appends
includeIfdirective to the global gitconfig - Prints out public SSH and GPG keys for easy copying into Git hosting services (GitHub, GitLab, etc.)
Newly created profile directory looks like this:
myProfile/
├── .gitconfig
└── .ssh
├── id_profile_ssh
└── id_profile_ssh.pub
When inside myProfile directory (or any of its subdirectories!) git will use the newly created SSH keys and GPG signing key.
All you need to do is to run the git_add_profile.sh. You can either copy-paste the script content into a new file or:
-
Download the script and save it in your
localbin:mkdir -p ~/bin sudo curl -sS https://raw.githubusercontent.com/Foxfactory-pl/git-profiles/refs/heads/main/git_add_profile.sh -o /usr/local/bin/git-add-profile -
Make it executable:
sudo chmod +x /usr/local/bin/git-add-profile
-
Run the script:
git-add-profile
