Skip to content

Commit 8433ba1

Browse files
committed
feat: add LICENSE and README files for project documentation
1 parent 7946951 commit 8433ba1

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 dominusmmp
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

readme.md

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
# GitSwitch
2+
3+
A tiny tool to switch between GitHub accounts using the `gh` CLI and configure Git user settings.
4+
5+
## Features
6+
7+
- Switch GitHub accounts with `gh auth switch`.
8+
- Set global or local (`--single`) Git user.name and user.email.
9+
- Support for custom email (`--email`) and hostname (`--hostname`).
10+
- Unset local Git settings with `--unset-single`.
11+
12+
## Installation
13+
14+
### Automatic Installation/Update
15+
16+
Run one of the following commands to download and execute the installer:
17+
18+
Using `curl`:
19+
20+
```bash
21+
curl -fsSL https://git.new/gitswitch | bash
22+
```
23+
24+
Using `wget`:
25+
26+
```bash
27+
wget -qO- https://git.new/gitswitch | bash
28+
```
29+
30+
This installs `gitswitch` to `/usr/local/bin` or `$HOME/.local/bin` and sets up dependencies (`gh`, `jq`).
31+
32+
### Manual Installation
33+
34+
In case the automatic installer fails:
35+
36+
1. **Download the script**:
37+
38+
```bash
39+
curl -fsSL "https://git.new/git-switch" -o gitswitch.sh
40+
```
41+
42+
or
43+
44+
```bash
45+
wget -qO gitswitch.sh "https://git.new/git-switch"
46+
```
47+
48+
2. **Make it executable**:
49+
50+
```bash
51+
chmod +x gitswitch.sh
52+
```
53+
54+
3. **Move to a bin directory**:
55+
56+
```bash
57+
sudo mv gitswitch.sh /usr/local/bin/gitswitch
58+
```
59+
60+
or
61+
62+
```bash
63+
mv gitswitch.sh $HOME/.local/bin/gitswitch
64+
```
65+
66+
4. **Ensure dependencies**: Install `git`, `gh`, and `jq` using your package manager (e.g., `apt`, `dnf`, `brew`).
67+
68+
5. **Add to PATH** (if using `$HOME/.local/bin`):
69+
70+
```bash
71+
echo 'export PATH="$PATH:$HOME/.local/bin"' >> ~/.bashrc
72+
source ~/.bashrc
73+
```
74+
75+
## Usage
76+
77+
```bash
78+
gitswitch [--single] [--hostname <host>] [--email <email>] <username>
79+
gitswitch --unset-single
80+
gitswitch -h | --help
81+
```
82+
83+
- `<username>`: GitHub username to switch to.
84+
- `--single`: Apply settings to the current repository only.
85+
- `--unset-single`: Remove local Git settings.
86+
- `--hostname`: Specify GitHub instance (default: github.com).
87+
- `--email`: Use a custom email instead of the default noreply email.
88+
89+
## Examples
90+
91+
Switch to a global GitHub account:
92+
93+
```bash
94+
gitswitch myusername
95+
```
96+
97+
Switch for the current repository only:
98+
99+
```bash
100+
gitswitch --single myusername
101+
```
102+
103+
Use a custom email and hostname:
104+
105+
```bash
106+
gitswitch --hostname github.company.com --email user@company.com myusername
107+
```
108+
109+
Unset local repository settings:
110+
111+
```bash
112+
gitswitch --unset-single
113+
```
114+
115+
## Notes
116+
117+
- Ensure you are logged in with `gh auth login -u <username> -h <hostname>` before switching.
118+
- Local option (`--single`) only affects the current repository's git user settings; Still the `gh` user change applies globally (even if `--single` is used).
119+
120+
## License
121+
122+
Licensed under the MIT License. See [LICENSE](LICENSE) for details.

0 commit comments

Comments
 (0)