Skip to content

Git Profile is a CLI tool that streamlines managing multiple Git identities, letting you effortlessly create, update, and switch between profiles.

License

Notifications You must be signed in to change notification settings

b4nd/git-profile

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Git Profile

License Go Bugs Code Smells Duplicated Lines (%) Lines of Code Reliability Rating Security Rating Technical Debt Maintainability Rating Vulnerabilities

Overview

Git Profile is a command-line application developed in Go, designed to manage multiple Git profiles efficiently. It provides a suite of commands to create, update, delete, and switch between different user profiles, making it easier to handle various identities across different Git repositories. This tool is particularly useful for developers who work on multiple projects with different user credentials.

Example Use Case

Imagine a developer working on both open-source and corporate projects. They need to switch between different Git profiles seamlessly to ensure commits are associated with the correct email and username. Instead of manually changing Git configurations every time, they can use git-profile to quickly switch between predefined profiles, improving workflow efficiency.

git-profile

Commands Documentation

Command Description
git-profile current Displays the currently active profile.
git-profile [delete|del] Deletes a specified profile from the system.
git-profile get Retrieves details of a specific profile.
git-profile [list|ls] Lists all available profiles.
git-profile set Sets or updates a profile configuration.
git-profile use Switches to a specific profile for operations.
git-profile amend Updates email and name of the current profile last commit.
git-profile version Displays the current version of the application.
git-profile help Displays help information for the application.
git-profile completion Generates shell completion scripts.

Installation

Linux

curl -sL https://github.com/b4nd/git-profile/releases/download/v0.1.2/git-profile-v0.1.2-linux-amd64 -o git-profile
chmod +x git-profile 
mv git-profile /usr/local/bin/

macOS

curl -sL https://github.com/b4nd/git-profile/releases/download/v0.1.2/git-profile-v0.1.2-darwin-amd64 -o git-profile
chmod +x git-profile 
mv git-profile /usr/local/bin/

Windows

  1. Download the latest Windows executable from the releases page.
  2. Extract the archive.
  3. Move the git-profile-v0.1.2-darwin-amd64.exe file to a directory in your system PATH and rename it to git-profile.exe.
  4. Optionally, add the directory to the system PATH environment variable for easier access.
[System.Environment]::SetEnvironmentVariable("Path", $Env:Path + ";C:\\path\\to\\git-profile", [System.EnvironmentVariableTarget]::User)

Usage

To use the application, run the following command:

git profile [command] [flags]

More Examples

  • Create a new profile for a personal project:

    git profile set --workspace personal --name "Your Name" --email "name@example.com"

    This command sets up a new profile named personal with the given credentials.

  • List all existing profiles:

    git profile list

    Displays all available profiles currently stored.

  • Use a specific profile:

    git profile use personal

    Switches to the personal profile, applying its Git credentials.

  • Check the currently active profile:

    git profile current

    Shows which profile is currently in use.

  • Amend the last commit with the active profile's details:

    git profile amend

    Updates the latest commit with the email and name of the currently active profile.

  • Remove a profile:

    git profile delete personal

    Deletes the personal profile from the system.

Environment variables

Variable Description
GIT_PROFILE_PATH The path to the directory where the profiles are stored. Default is $HOME/.gitprofile.

Configuring GIT_PROFILE_PATH in .zshrc or .bashrc

If you want to specify a custom location for the Git Profile configuration, you can set the GIT_PROFILE_PATH environment variable in your shell configuration file.

For Windows Subsystem for Linux (WSL), you can add the following lines to your ~/.zshrc or ~/.bashrc:

# Example of a shared Git profile on Windows through WSL
export GIT_PROFILE_PATH="/mnt/c/Users/<USER>/.gitprofile"

After adding the line, apply the changes by running:

source ~/.zshrc  # If using zsh
source ~/.bashrc  # If using bash

DevContainer Support

This project includes support for DevContainers, allowing developers to quickly set up a consistent development environment using VS Code Remote - Containers or GitHub Codespaces.

How to Use

  1. Ensure you have Docker installed and running.
  2. Open the project in VS Code.
  3. Install the Dev Containers extension if you haven't already.
  4. Open the Command Palette (Ctrl+Shift+P or Cmd+Shift+P on macOS) and select Remote-Containers: Reopen in Container.

This will automatically set up all dependencies and configurations needed for development.

Requirements

Build

  1. Clone the repository:
    git clone https://github.com/b4nd/git-profile.git
  2. Change into the project directory:
    cd git-profile
  3. Install the dependencies:
    go mod tidy
  4. Run the tests:
    task test
  5. Run the following command to install the application:
    task build

build output will be in the bin directory.

Example usage during development

Below are examples of how to use each command, along with explanations of their purpose:

  • Set a new profile:

    task run -- set \
       --workspace company \
       --name "Your Name" \
       --email "name@example.com"

    This command creates a new Git profile under the workspace company, assigning the specified name and email.

  • List all profiles:

    task run -- list

    Displays all available Git profiles configured in the system.

  • Switch to a specific profile:

    task run -- use company

    Activates the Git profile associated with company, ensuring that subsequent Git commits use the corresponding credentials.

  • Check the currently active profile:

    task run -- current

    Shows the details of the currently active Git profile, including name and email.

Contributing

  1. Fork the repository.
  2. Create a new branch:
    git checkout -b feature-name
  3. Commit your changes:
    git commit -m 'Add new feature'
  4. Push to the branch:
    git push origin feature-name
  5. Open a pull request.

Authors

License

This project is licensed under the MIT License. See the LICENSE file for details.

Acknowledgements

SonarQube Cloud

About

Git Profile is a CLI tool that streamlines managing multiple Git identities, letting you effortlessly create, update, and switch between profiles.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •