g-cli 0.1.0

Git that talks back. A human-friendly CLI wrapper for Git.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
<div align="center">

# `g` — Git that talks back.


**Stop memorizing Git commands. Start telling Git what you want.**

[![Rust](https://img.shields.io/badge/built%20with-Rust-orange?style=flat-square&logo=rust)](https://www.rust-lang.org/)
[![License: MIT](https://img.shields.io/badge/license-MIT-blue?style=flat-square)](LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen?style=flat-square)](http://makeapullrequest.com)
[![crates.io](https://img.shields.io/crates/v/g-cli?style=flat-square&color=orange)](https://crates.io/crates/g-cli)
[![GitHub stars](https://img.shields.io/github/stars/alonsovm44/g?style=flat-square)](https://github.com/alonsovm44/g/stargazers)

<br />

*A CLI wrapper that makes Git feel easier than ever*

[Install](#install) · [Quick Start](#quick-start) · [Commands](#-commands) · [Why g?](#-why-g) · [Demos](#-demos)

</div>

---

## The problem: 😱 You just committed your API keys.


You accidentally committed a `.env` file with all your API keys. Or a 200MB binary. Or both. You Google *"how to undo git commit"* and get 47 different StackOverflow answers with `reset`, `revert`, `--soft`, `--hard`, `--mixed`, `HEAD~1`, `ORIG_HEAD`...

**With `g`?**

```
$ g undo

  ⏪ Last action detected:
    💾 Commit: "added environment config"

  Files in this commit:
    .env                 | 12 ++++++
    src/config.rs        | 3 ++-

  What would you like to do?
  > Undo commit, keep all changes staged
    Undo commit, keep changes unstaged
    Undo commit and discard all changes
    Cancel

  ✔ Commit undone.
  Your changes are staged and ready to re-commit.
```

That's it. No Googling. No panic. Just tell Git what you want.

---

## Install


```bash
# With Cargo (Rust toolchain)

cargo install g-cli

# Or build from source

git clone https://github.com/alonsovm44/g.git
cd g
cargo build --release
cp target/release/g /usr/local/bin/  # or C:\Tools\ on Windows
```

<details>
<summary><strong>Requirements</strong></summary>

- Git (any modern version)
- Rust 1.70+ (to build from source)
- Works on **Windows**, **macOS**, and **Linux**

</details>

---

## Quick Start


```bash
g                    # Show friendly status (default)
g save "my changes"  # Stage + commit in one step
g undo               # Undo anything, safely
g push               # Push with a preview first
```

That's the 80% of Git you use daily. Now it takes zero brain power.

---

## 📖 Commands


### `g status` — Know where you stand


```
$ g status

  You're on branch: feature/auth

  Staged changes:
    + src/session.rs

  Unstaged changes:
    ~ src/login.rs
    ? src/tmp.js

  Staged: 1 file(s)  Unstaged: 2 file(s)

  ⚠ You're 3 commit(s) behind remote

  Suggested next steps:
    → g save "describe your changes"
    → g undo  (undo last action)
```

### `g save "message"` — Commit without the ceremony


Stages everything and commits. One command. One thought.

```
$ g save "add session handling"

  Staging all changes...
  Creating commit...

  ✔ Commit created:
    "add session handling"

  Files:
    + src/session.rs
    ~ src/login.rs

  You're now 1 commit(s) ahead of origin/feature/auth
```

### `g undo` — The killer feature ⭐


**Undo *anything*.** Commits, merges, pulls, branch switches, rebases — all with a preview of what will happen before it does.

```
$ g undo

  ⏪ Last action detected:
    💾 Commit: "add session handling"

  Files in this commit:
    src/session.rs       | 45 ++++++++++++
    src/login.rs         | 3 ++-

  What would you like to do?
  > Undo commit, keep all changes staged
    Undo commit, keep changes unstaged
    Undo commit and discard all changes
    Cancel

  ✔ Commit undone.
  Your changes are staged and ready to re-commit.
```

**Undo a branch switch:**
```
$ g undo

  ⏪ Last action detected:
    🔄 Switched from 'main' to 'feature/auth'

  What would you like to do?
  > Switch back to 'main'
    Cancel

  ✔ Switched back to 'main'.
```

**Undo timeline** — rewind to *any* point in your history:
```
$ g undo --list

  Undo timeline:
  Pick any action to rewind to the state before it.

  > 💾 Commit: "add session handling"          (2 minutes ago)
    🔄 Switched from 'main' to 'feature/auth'  (5 minutes ago)
    💾 Commit: "fix login bug"                  (1 hour ago)
    ⬇️ Pulled from remote                       (2 hours ago)
    🔀 Merged branch 'feature/ui'               (yesterday)
```

### `g explain` — "What the hell did I just do?"

```
$ g explain

  Recent actions:

  1)  You committed: "add session handling"
      2 minutes ago

  2)  You switched to branch feature/auth
      5 minutes ago

  3)  You committed: "fix login bug"
      1 hour ago

  Current state:
    ✔ Clean working directory
    On branch: feature/auth
    ↑ 2 commit(s) ahead of remote
```

### `g log` — Human-readable history


```
$ g log

  Your recent work:

  🟢 add session handling                (2 hours ago)
  🟢 fix login bug                       (3 hours ago)
  🟢 refactor auth middleware            (yesterday)
  🔵 merge branch 'feature/ui'           (2 days ago)

  Tip: Run `g log --story` to see what changed in plain English
```

### `g log --story` — Narrate your project


```
$ g log --story

  Project story:

  You worked on authentication:

    - Refactored middleware to simplify request handling
    - Fixed a bug in login validation
    - Added session handling to persist user state

  Then, you merged branch 'feature/ui' into your current branch.

  Current focus:
    Branch feature/auth — last: "add session handling"
```

### `g switch <branch>` — Branch without confusion


```
$ g switch login-fix

  Branch 'login-fix' does not exist.

  Options:
  > Create new branch from current (feature/auth)
    Create from main
    Cancel

  ✔ Created and switched to 'login-fix' (from main)
```

### `g whoops "new message"` — Fix a typo in your commit


```
$ g whoops "fix login validation"

  Fixing last commit message...

  Before: "fix loing validaiton"
  After:  "fix login validation"

  ✔ Commit message updated.
```

### `g push` — Push without anxiety


```
$ g push

  You're about to push:

    Branch:      feature/auth
    Commits:     3
    Destination: origin/feature/auth

  Summary:
    - add session handling
    - fix login bug
    - cleanup auth flow

  Proceed? (y/n)

  ✔ Pushed 3 commit(s) to origin/feature/auth.
```

### `g sync` — Pull without fear


```
$ g sync

  Pulling latest changes from remote...

  ⚠ Merge conflict detected!

  Conflicting files:
    ! src/login.rs

  What would you like to do?
  > Accept incoming changes (theirs)
    Keep your version (ours)
    Abort merge (go back to before sync)
```

### `g stash` — Named stashes that make sense

```bash
g stash save "WIP auth stuff"   # Stash with a name you'll remember
g stash list                    # See all your stashes
g stash pop                     # Pick which stash to restore
```

### `g clean` — Prune dead branches


```
$ g clean

  Analyzing branches...

  Safe to delete (already merged):
    - feature/old-login  (last commit 2 weeks ago)
    - test/tmp-api       (last commit 10 days ago)

  Possibly unsafe (not merged):
    ? wip/refactor-auth  (last commit 3 days ago)

  Delete 2 safe branch(es)? (y/n)

  ✔ 2 branch(es) cleaned up.
```

### `g map` — Visualize your repo


Exports your commit graph as a Graphviz `.dot` file with a dark theme.

```bash
g map                          # → repo-map.dot
g map -o my-graph.dot          # Custom output path
g map --max-commits 100        # Include more history
dot -Tpng repo-map.dot -o repo-map.png  # Render it
```

---

## 🧠 Why `g`?


Most Git wrappers just alias commands. They don't actually help you *understand* what's happening.

`g` is different:

| Problem | Git | `g` |
|---|---|---|
| "What's going on?" | `git status` → wall of text | `g status` → clear summary + next steps |
| "Save my work" | `git add -A && git commit -m "..."` | `g save "..."` |
| "I messed up" | Google "how to undo git ___" | `g undo` → pick what you want |
| "What did I just do?" | `git reflog` → cryptic hashes | `g explain` → plain English |
| "Show my history" | `git log --oneline` → just hashes | `g log` → emoji timeline |
| "Fix my typo" | `git commit --amend -m "..."` | `g whoops "..."` |
| "Is it safe to push?" | `git log origin/branch..HEAD` 🤔 | `g push` → preview first |
| "Clean up branches" | Manually check & delete each one | `g clean` → auto-detect safe deletions |

**`g` doesn't replace Git.** It's the friendly layer on top for the 80% of Git you do every day. Drop to `git` for the other 20%.

---

## 🛠 Built With


- **Rust** — fast, single binary, no runtime
- **[clap]https://github.com/clap-rs/clap** — argument parsing
- **[colored]https://github.com/colored-rs/colored** — terminal colors
- **[dialoguer]https://github.com/console-rs/dialoguer** — interactive prompts

---

## 📋 Full Command Reference


| Command | Description |
|---|---|
| `g` / `g status` | Friendly, actionable repo status |
| `g save "msg"` | Stage all + commit in one step |
| `g undo` | Undo last action safely with preview |
| `g undo --list` | Interactive undo timeline |
| `g explain` | Recent actions in plain English |
| `g log` | Emoji-tagged commit history |
| `g log --story` | Narrative project history |
| `g switch <branch>` | Smart branch switching (creates if needed) |
| `g whoops "msg"` | Fix last commit message |
| `g push` | Push with preview + confirmation |
| `g sync` | Pull with guided conflict resolution |
| `g stash save "msg"` | Named stash |
| `g stash pop` | Interactive stash restore |
| `g stash list` | List all stashes |
| `g clean` | Prune merged/stale branches safely |
| `g map` | Export repo graph as Graphviz `.dot` |

---

## 🎬 Demos


| | |
|---|---|
| **😱 "You just committed your API keys."** | **⚡ Your entire daily workflow** |
| `g undo` saves you in 5 seconds. No Googling. | `g``g save``g push`. That's your whole morning. |
| ![g undo demo]casts/demo1.gif | ![g daily flow demo]casts/demo2.gif |

<div align="center">

| **🕰️ The Git time machine** |
|---|
| It's Friday. Something broke. `g undo --list` lets you pick any point to rewind to. |
| ![g time machine demo]casts/demo3.gif |

</div>

---

<div align="center">

**`g` — because Git shouldn't require a PhD.**

⭐ Star this repo if you think Git should be easier.

</div>