Giter VIP home page Giter VIP logo

git-profile's Introduction

๐Ÿ”€ Git Profile

Bash script in order to switch between various Git profiles, where each profile is represented as .gitconfig file.

A scenario could be:

  • A Git profile with the working email (e.g. [email protected]) and ssh-key defined to access a repository hosted on the intranet;
  • A different Git profile with the personal email (e.g. [email protected]) to access a repository hosted on GitHub (or any other hosting)

Getting Started

These instructions will get you a copy of the project up and running on your local machine for usage, development and testing purposes.

Prerequisites

  • Git
  • Shell/Bash ๐Ÿคท๐Ÿปโ€โ™‚๏ธ

Installing

  1. Download the latest release or clone the repository:
$ git clone https://github.com/imgios/git-profile.git
  1. Make the script executable:
$ chmod +x git-profile
(Optional) Global installation and Bash completion โžก
  • Install the script:
$ sudo install -o root -g root -m 0755 git-profile /usr/local/bin/git-profile
  • Source the bash completion:
$ echo "source <(git-profile completion)" >> .bashrc
  1. Create the ~/.gitprofile dir and save your actual .gitconfig in the profiles path:
# Manual
$ mkdir ~/.gitprofile && cp ~/.gitconfig ~/.gitprofile/default.gitconfig # You can use any name you wish to use
# Using the script
$ git-profile save <name> # If you have the alias you can use git-profile -s
  1. Create a new .gitconfig file in the profiles path for each account you want to configure (e.g. github.gitconfig, gitlab.gitconfig, ...), and switch between them using the script:
$ git-profile set <profile-name>

Usage

Before starting make sure you have saved (see Installing - Point 3) your currently used .gitconfig, otherwise you will risk to lose it. Then navigate in the ~/.gitprofile path and create a new .gitconfig for each profile you want to setup.

GitConfig example โžก
# Example .gitconfig used as Git profile
[user]
  name = Your Name
  email = [email protected]

[color]
  ui = auto

[alias]
  co = checkout
  ci = commit
  st = status
  br = branch -av
  brdel = branch -D

  # Show all configured aliases
  aliases = !git config --list | grep 'alias\\.' | sed 's/alias\\.\\([^=]*\\)=\\(.*\\)/\\1\\ \t => \\2/' | sort

  # Log format view
  lg = log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit --date=relative
  hist = log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short

When you're done populating the profiles path, you can start using the script:

$ git-profile help
USAGE: git-profile <command> [profile] [options]
 
  where: <profile-name> is a <profile-name>.gitconfig files in /home/imgios/.gitprofile
 
  commands:
    set           Set the profile specified as third argument.
    save          Save the profile in-use as default.gitconfig in /home/imgios/.gitprofile.
                  An argument can be passed to customize the profile name.
    list          List all the available profiles present in /home/imgios/.gitprofile
    help          Show this help test.
    version       Show git-profile version.
 
  flags:
    -d,--dir      Specify the Git Profiles directory that will be used to retrieve/store all profiles.
    -v,--verbose  Increase the log level to DEBUG.
 
  examples:
    git-profile set github
    git-profile save work -d /etc/.gitprofile
    git-profile list
 
  Feedbacks and issues can be reported at https://github.com/imgios/git-profile

Contributing

Please read CONTRIBUTING.md for details on the code of conduct, and the process for submitting pull requests.

See also the list of contributors who participated in this project.

Versioning

We use SemVer for versioning. For the versions available, see the tags on this repository.

The current version in development can always be found in the dev branch.

License

This project is licensed under the MIT License - see the LICENSE file for details

git-profile's People

Contributors

imgios avatar

Stargazers

 avatar  avatar  avatar  avatar

git-profile's Issues

Using verbs as commands

Would be cool to use verbs instead of options for a set of actions, just like git-profile <verb> [<profile-name>] [options]

For instance:

  • View a Git profile: git-profile get <profile-name>
  • Save a Git profile: git-profile save <profile-name> [--dir <path>]
  • List the available Git profiles: git-profile list
  • Delete a Git profile: git-profile delete <profile-name>
  • Get Git profile version: git-profile version

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.