Git custom subcommand for switching the global ~/.gitconfig between named
profile files.
git profile add work # Save the current ~/.gitconfig as "work"
git profile add personal --from ~/personal.gitconfig
git profile list # See stored profiles
git profile work # Replace ~/.gitconfig with "work"
git profile # Print the active profile name
git profile show # Inspect the active profile
git profile diff # Compare active profile with ~/.gitconfig
git profile export work ./work.gitconfigSupported platforms:
- macOS, Linux, and WSL 2
- amd64 and arm64
Install with Homebrew:
brew install mznu/tap/git-profileOr download a release archive for your OS and architecture, then install it manually:
tar -xzf git-profile_1.0.0_linux_amd64.tar.gz git-profile
mkdir -p ~/.local/bin
install -m 0755 git-profile ~/.local/bin/git-profileUse the matching archive name for macOS (darwin) or ARM (arm64). Make sure
~/.local/bin is on your PATH.
If macOS blocks a manually downloaded binary, remove the quarantine attribute after verifying that the archive came from a trusted release:
xattr -d com.apple.quarantine ~/.local/bin/git-profileNative Windows binaries are not published. On Windows, use WSL 2 and install
git-profile inside the WSL distribution with the macOS and Linux instructions
above. The WSL binary manages the WSL user's ~/.gitconfig.
Build from source with Go:
go build -o git-profile ./cmd/git-profile
export PATH="$PWD:$PATH"All commands are run as git profile ....
| Command | Description |
|---|---|
(no arguments) |
Print the active profile name, or none when no profile is active. |
list |
List stored profiles. The active profile is marked with *. |
add NAME |
Create a profile by copying the current ~/.gitconfig. |
add NAME --from PATH |
Create a profile from another Git config file. |
NAME |
Switch ~/.gitconfig to the named profile. |
show [NAME] |
Print a stored profile without switching. When NAME is omitted, show the active profile. |
diff [NAME] |
Show file differences between a stored profile and the current ~/.gitconfig. When NAME is omitted, diff the active profile. |
remove NAME |
Remove a stored profile. The active profile cannot be removed. |
rename OLD [NEW] |
Rename a stored profile. When NEW is omitted, prompt for it. |
export NAME [DESTINATION] |
Copy a stored profile to a file. Use --force to overwrite an existing destination. |
Run git profile -h, git profile help [command], or
git profile [command] -h for command-specific help. Profile names can contain
letters, numbers, ., _, and -, and cannot use reserved command names.
Built-in shell auto-completion is not currently published. git-profile is
installed as a Git custom subcommand and used as git profile; generic Cobra
completion scripts target profile as a standalone command instead of the Git
subcommand form, so the default completion command is intentionally disabled.
git profile add NAMEcopies the current~/.gitconfiginto a named profile file. Use--fromto copy another Git config file instead.- Profile files are stored as
~/.config/git-profile/profiles/NAME.gitconfig. - Running
git profile NAMEvalidates the stored profile withgit config, then replaces~/.gitconfigwith that profile using an atomic file write. - The active profile name and switch time are recorded in
${XDG_CONFIG_HOME:-~/.config}/git-profile/state.json. git profile list,show,diff,rename,remove, andexportoperate on those stored profile files;removedoes not delete the active profile.
Releases are automated with GoReleaser. Pushing a SemVer tag that starts with
v runs tests, builds Linux and macOS artifacts, uploads checksums,
and creates a GitHub Release.
git tag v1.0.0
git push origin v1.0.0Validate the release configuration locally before tagging:
goreleaser release --snapshot --clean