# @joebochill/git-switch

> Switch between different .gitconfig files easily

Latest version **0.0.1** (published 2019-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @joebochill/git-switch
pnpm add @joebochill/git-switch
yarn add @joebochill/git-switch
bun add @joebochill/git-switch
```

Provides the command `gitswitch`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2019-06-16 |
| First published | 2019-06-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Joseph Boyle |
| Maintainers | joebochill |
| Keywords | gitconfig, switch, utility, shell, npm |

## Links

- npm: https://www.npmjs.com/package/@joebochill/git-switch
- Repository: https://github.com/joebochill/git-switch
- Homepage: https://github.com/joebochill/git-switch#readme
- Issues: https://github.com/joebochill/git-switch/issues
- npm.io page: https://npm.io/package/@joebochill/git-switch

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2019-06-16

## README

# Git-Switch
A utility to switch between different .gitconfig files.

> This utility is based on and borrows much of the underlying code from [NPMRC](https://github.com/deoxxa/npmrc), which does the same thing but for .npmrc files.

## Overview
If you've ever had to work in various environments with different proxy settings, or you have different github accounts for different projects, it can be a pain to constantly adjust your .gitconfig file manually. This utility allows you to maintain multiple named versions of your .gitconfig file and switch between them seamlessly with a simple terminal command. It also tries to protect you from yourself by making sure you don't accidentally overwrite a .gitconfig file that you actually want to keep.

## Installation

``` sh
npm install -g @joebochill/git-switch
```

## Usage

```
gitswitch --help

gitswitch

  A utility to switch between different .gitconfig files.

Usage:
  gitswitch                 list all profiles
  gitswitch [name]          change gitconfig profile (uses fuzzy matching)
  gitswitch -c [name]       create a new gitconfig profile called name
```

#### Initialisation

Calling `gitswitch` without arguments creates an `~/.gitconfigs/` directory if it doesn't exist,
and copies your current `~/.gitconfig` as the 'default' .gitconfig profile.

```
gitswitch
Creating /Users/joe/.gitconfigs
Making /Users/joe/.gitconfig the default gitconfig file
Activating .gitconfig 'default'
```

#### Create a new .gitconfig profile

```
gitswitch -c newprofile
Removing old .gitconfig (/home/joe/.gitconfigs/default)
Activating .gitconfig 'newprofile'
```

A blank profile will be created.

#### List available .gitconfig profiles

```
gitswitch 
Available gitconfigs:
    
* default
  work
```

#### Switch to a specific .gitconfig 

```
gitswitch work
Removing old .gitconfig (/Users/joe/.gitconfigs/default)
Activating .gitconfig 'work'
```

You can also pass only the first few characters of a profile and `gitswitch` will
autocomplete the profile's name.

```
gitswitch def
Removing old .gitconfig (/Users/joe/.gitconfigs/work)
Activating .gitconfig 'default'
```

`gitswitch <name>` will also go to some lengths to make sure you don't overwrite anything you might care about:

```
gitswitch default
Removing old .gitconfig (/Users/joe/.gitconfigs/work)
Activating .gitconfig 'default'
gitswitch default  
Current .gitconfig (/Users/joe/.gitconfig) is already 'default' (/Users/joe/.gitconfigs/default)
rm ~/.gitconfigs
touch ~/.gitconfigs
gitswitch default
Current .gitconfig (/Users/joe/.gitconfigs) is not a regular file, not removing it
rm ~/.gitconfigs
gitswitch default
Activating .gitconfig 'default'
```

> **Note For Windows Users:**
You may have to run gitswitch in a shell (cmd, PowerShell, Git Bash, etc) with elevated (Administrative) privileges to get it to run.

## Environment Variables
* `GITSWITCH_STORE` - Path to directory of profiles. Default: `~/.gitconfigs/`
* `GITSWITCH` - Path to the gitconfig file used by git. Default: `~/.gitconfig`

## License
MIT. A copy is included with the source.

---
_Source: https://npm.io/package/@joebochill/git-switch · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
