Skip to content

Repository files navigation

git-profile

git-profile

CI Go Report Card License: MIT

Manage multiple Git identities. Never commit with the wrong email again.

$ git profile use Personal

  ✓ Switched to profile "Personal"

    Scope:             Local
    Repository:        my-side-project
    Name:              Malay Kumar
    Email:             malay@gmail.com

git-profile is a Git extension that lets you define named profiles (work, personal, open-source) and switch between them per repository. It integrates with Git's native extension system — just type git profile.

Part of the gitx ecosystem.

The Problem

If you use Git with multiple accounts, you've probably:

  • Committed to a work repo with your personal email
  • Had to git config user.email ... in every new clone
  • Forgotten which identity a repository is using
  • Wished Git had a built-in "profile" concept

git-profile fixes all of this.

Quick Start

# Install
go install github.com/Malay-dev/gitx-profile@latest

# Create profiles
git profile add personal --name "Alice" --email "alice@gmail.com"
git profile add work --name "Alice" --email "alice@acmecorp.com"

# Or inherit from your existing global config
git profile add work --from global

# Switch identity (current repo only)
git profile use work

# See what's active
git profile current

# Inspect a repo's full identity setup
git profile show

Install

From source (requires Go 1.22+)

go install github.com/Malay-dev/gitx-profile@latest

The binary is named git-profile. Git automatically discovers it as git profile.

From GitHub Releases

Download the binary for your platform from Releases, extract it, and place it somewhere in your PATH:

# macOS / Linux
sudo mv git-profile /usr/local/bin/

# Or without sudo
mkdir -p ~/.local/bin
mv git-profile ~/.local/bin/

Verify installation

git profile --help

If Git finds it, you're good.

Commands

git profile add <name>

Create a new profile.

# Interactive
git profile add work

# With flags
git profile add work --name "Alice" --email "alice@acmecorp.com"

# Inherit from global git config (with confirmation prompt)
git profile add work --from global

# Clone from an existing profile (override what's different)
git profile add oss --from work --email "alice@opensource.org"

git profile use <name>

Switch to a profile. Writes to the current repo by default (not global).

git profile use work
# ✓ Switched to profile "work"
#
#   Scope:             Local
#   Repository:        inventory-service
#   Name:              Alice
#   Email:             alice@acmecorp.com

Use --global to change the global default:

git profile use personal --global

git profile current

Show the active identity and which profile it matches.

git profile current
# ✓ Profile: work
#
#   Name:              Alice
#   Email:             alice@acmecorp.com
#   Repository:        inventory-service
#   Scope:             Local (.git/config)

git profile list

List all saved profiles. Active one is marked with *.

git profile list
# * work <alice@acmecorp.com>
#   personal <alice@gmail.com>
#   oss <alice@opensource.org>

git profile show

Discover the full identity configuration of the current repository.

git profile show
# === Repository ===
#
#   Name:              inventory-service
#   Remote (origin):   git@github.com:AcmeCorp/inventory-service.git
#   Branch:            main
#
# === Identity ===
#
#   user.name:         Alice
#   user.email:        alice@acmecorp.com
#
#   Source breakdown:
#     user.name:       Alice (local — .git/config)
#     user.email:      alice@acmecorp.com (local — .git/config)
#
# === Profile ===
#
#   ✓ Matched: work

git profile check

Verify the current identity matches a known profile. Useful in pre-commit hooks.

git profile check
# ✓ Identity matches profile "work"

git profile check --quiet
# (exit code 0 = match, 1 = mismatch)

git profile doctor

Run diagnostics on your Git identity setup.

git profile doctor

git profile remove <name>

Delete a saved profile. Does not change any existing git config.

git profile remove old-work

git profile policy list / git profile policy create

Manage identity policies — control which profiles are allowed in which repos.

git profile policy create
# Policy name: acme-corp
# Remote patterns: github.com/AcmeCorp/*
# Allowed profiles: work
# Mode (strict/warning/advisory): strict
#
# ✓ Policy "acme-corp" created

How It Works

Profiles are stored in ~/.gitprofiles:

[profile "personal"]
  name = Alice
  email = alice@gmail.com

[profile "work"]
  name = Alice
  email = alice@acmecorp.com
  signingkey = ABC123

When you run git profile use work, the tool executes:

git config user.name "Alice"
git config user.email "alice@acmecorp.com"

That's it. No magic. Git remains the source of truth.

Scope

git profile use work           → .git/config (this repo only)
git profile use work --global  → ~/.gitconfig (all repos without local override)

Policies

Policies prevent using the wrong profile in a repo. Two levels:

User-level (~/.git-profile/policies.yaml):

policies:
  - name: acme-corp
    remotePatterns:
      - "github.com/AcmeCorp/*"
    allowedProfiles:
      - work
    mode: strict

Repo-level (.gitprofile.yml in repo root):

organization: AcmeCorp
allowedProfiles:
  - work
mode: strict

Modes: strict (blocks), warning (asks), advisory (suggests).

Environment Variables

Variable Description Default
GITX_PROFILES_PATH Custom path to profiles file ~/.gitprofiles
GITX_POLICIES_PATH Custom path to policies file ~/.git-profile/policies.yaml

License

MIT

About

Never commit with the wrong Git email again. Manage multiple identities (work, personal, open-source) and switch per repository with policies and guardrails.

Topics

Resources

Contributing

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages