git-sync-tui 0.1.5 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -15,14 +15,15 @@
15
15
 
16
16
  <p align="center">
17
17
  Cherry-pick commits from remote branches with an intuitive terminal UI.<br>
18
- Select specific commits, preview changes, and sync with <code>--no-commit</code> mode for safe review.
18
+ Multi-select commits, preview diff stats, handle conflicts interactively, and sync safely with backup &amp; stash protection.
19
19
  </p>
20
20
 
21
21
  <p align="center">
22
22
  <a href="#-features">Features</a> ·
23
23
  <a href="#-quick-start">Quick Start</a> ·
24
24
  <a href="#-installation">Installation</a> ·
25
- <a href="#-workflow">Workflow</a>
25
+ <a href="#-workflow">Workflow</a> ·
26
+ <a href="#%EF%B8%8F-cli-options">CLI Options</a>
26
27
  </p>
27
28
 
28
29
  <p align="center">
@@ -35,11 +36,18 @@
35
36
 
36
37
  ## ✨ Features
37
38
 
38
- - 🎯 **Multi-select commits** — Cherry-pick non-consecutive commits with Space / Enter
39
+ - 🎯 **Multi-select commits** — Select non-consecutive commits with Space, range-select with Shift+↑↓, toggle all with `a`, invert with `i`
39
40
  - 🔍 **Branch search** — Fuzzy filter branches by keyword
40
- - 👀 **Diff preview** — See `--stat` summary of selected commits before executing
41
- - ⚡ **Safe mode** — `--no-commit` stages changes for review, never auto-commits
42
- - ⚠️ **Conflict handling** — Clear display of conflicted files when cherry-pick fails
41
+ - 👀 **Diff preview** — Scrollable `--stat` summary panel with `j`/`k` navigation
42
+ - ⚡ **Dual mode** — `--no-commit` stages changes for review, or commit individually preserving original messages
43
+ - 🔀 **One-by-one cherry-pick** — Executes commits sequentially, pausing on conflicts for interactive resolution
44
+ - ⚠️ **Conflict handling** — Shows conflicted files, resolve in another terminal, then continue/abort/quit
45
+ - 🛡️ **Safe backup** — Creates a backup branch before execution; full rollback on abort
46
+ - 📦 **Auto stash** — Detects uncommitted changes, offers to stash, auto-restores after sync
47
+ - 🔄 **Stash recovery** — Detects interrupted sessions and offers to recover stashed changes
48
+ - 🌿 **Branch check** — Auto-creates target branch from main/master if not on it
49
+ - ✅ **Synced markers** — Marks already-synced commits as `[synced]` in the commit list
50
+ - 🖥️ **CLI mode** — Non-interactive mode with `-r -b -c` flags for scripting
43
51
  - 🌐 **Universal** — Works in any git repository, any language
44
52
 
45
53
  ## 🚀 Quick Start
@@ -64,35 +72,95 @@ npm install -g git-sync-tui
64
72
  ## 🔄 Workflow
65
73
 
66
74
  ```
67
- Select Remote → Select Branch → Multi-select Commits → Preview Changes
68
-
69
- Review & Commit manually ← Cherry-pick --no-commit (staged, not committed)
75
+ Check workspace → Select Remote → Select Branch → Branch Check → Multi-select Commits
76
+
77
+ Auto stash Preview diff stats
78
+ (if needed) ↓
79
+ Confirm & choose mode
80
+
81
+ Cherry-pick one-by-one (with backup)
82
+
83
+ Handle conflicts / Done
84
+
85
+ Restore stash & exit
70
86
  ```
71
87
 
72
88
  ## ⌨️ Keyboard Shortcuts
73
89
 
90
+ ### Commit Selection
91
+
74
92
  | Key | Action |
75
93
  |-----|--------|
76
- | `↑` `↓` | Navigate items |
94
+ | `↑` `↓` | Navigate commits |
77
95
  | `Space` | Toggle commit selection |
96
+ | `Shift`+`↑`/`↓` | Range select |
97
+ | `a` | Select all / Deselect all |
98
+ | `i` | Invert selection |
99
+ | `r` | Select from top to cursor |
100
+ | `j` / `k` | Scroll diff stat preview |
78
101
  | `Enter` | Confirm selection |
79
- | `y` / `n` | Confirm / cancel execution |
80
- | `/` | Search (in branch list) |
102
+ | `Esc` | Go back |
81
103
 
82
- ## 📋 After Sync
104
+ ### Confirm Panel
105
+
106
+ | Key | Action |
107
+ |-----|--------|
108
+ | `y` | Confirm execution |
109
+ | `n` | Cancel |
110
+ | `c` | Toggle commit mode (--no-commit / individual) |
111
+ | `m` | Toggle `-m 1` for merge commits |
112
+ | `Esc` | Go back |
83
113
 
84
- Changes are staged in your working tree (not committed). You can:
114
+ ### Conflict Handling
85
115
 
86
- ```bash
87
- # Review staged changes
88
- git diff --cached
116
+ | Key | Action |
117
+ |-----|--------|
118
+ | `c` | Continue (after resolving conflicts) |
119
+ | `a` | Abort (rollback all changes) |
120
+ | `q` | Quit (keep current state) |
89
121
 
90
- # Commit when ready
91
- git commit -m "sync: cherry-picked commits from feature-branch"
122
+ ## ⚙️ CLI Options
92
123
 
93
- # Or discard all changes
94
- git reset HEAD
95
124
  ```
125
+ Usage
126
+ $ git-sync-tui [options]
127
+
128
+ Options
129
+ -r, --remote <name> Remote name
130
+ -b, --branch <name> Remote branch name
131
+ -c, --commits <hashes> Commit hashes (comma-separated)
132
+ -n, --count <number> Number of commits to show (default: 100)
133
+ -m, --mainline Use -m 1 for merge commits
134
+ -y, --yes Skip confirmation
135
+ --no-stash Skip stash prompt
136
+ --list List remote branch commits and exit
137
+
138
+ Modes
139
+ No arguments Interactive TUI mode
140
+ -r -b --list List commits (plain text)
141
+ -r -b -c CLI mode, confirm before execution
142
+ -r -b -c --yes CLI mode, execute directly
143
+ -r or -r -b only TUI mode, skip completed steps
144
+
145
+ Examples
146
+ $ git-sync-tui # TUI mode
147
+ $ git-sync-tui -r upstream -b main --list # List commits
148
+ $ git-sync-tui -r upstream -b main -c abc1234 --yes # Execute directly
149
+ $ git-sync-tui -r upstream -b main -c abc1234,def5678 # Confirm then execute
150
+ $ git-sync-tui -r upstream # TUI mode, skip remote select
151
+ ```
152
+
153
+ ## 📋 After Sync
154
+
155
+ **--no-commit mode** — Changes are staged in your working tree (not committed):
156
+
157
+ ```bash
158
+ git diff --cached # Review staged changes
159
+ git commit -m "sync: cherry-picked commits from feature-branch" # Commit
160
+ git reset HEAD # Or discard all changes
161
+ ```
162
+
163
+ **Individual commit mode** — Original commit messages are preserved. Check with `git log`.
96
164
 
97
165
  ## 💡 Use Cases
98
166
 
@@ -107,8 +175,8 @@ git reset HEAD
107
175
  ```bash
108
176
  git clone https://github.com/KiWi233333/git-sync-tui.git
109
177
  cd git-sync-tui
110
- npm install
111
- npm start
178
+ pnpm install
179
+ pnpm start
112
180
  ```
113
181
 
114
182
  ## 🏗️ Tech Stack
@@ -116,6 +184,7 @@ npm start
116
184
  - [Ink](https://github.com/vadimdemedes/ink) — React for interactive CLI apps
117
185
  - [@inkjs/ui](https://github.com/inkjs/ui) — UI components for Ink
118
186
  - [simple-git](https://github.com/steveukx/git-js) — Git commands interface
187
+ - [meow](https://github.com/sindresorhus/meow) — CLI argument parsing
119
188
 
120
189
  ## 🤝 Contributing
121
190
 
package/README.zh-CN.md CHANGED
@@ -15,14 +15,15 @@
15
15
 
16
16
  <p align="center">
17
17
  通过直观的终端界面从远程分支 cherry-pick 提交。<br>
18
- 选择特定提交、预览变更,并使用 <code>--no-commit</code> 模式在提交前安全审查。
18
+ 多选提交、预览 diff 统计、交互式处理冲突,支持备份分支和 stash 保护机制。
19
19
  </p>
20
20
 
21
21
  <p align="center">
22
22
  <a href="#-功能特性">功能</a> ·
23
23
  <a href="#-快速开始">快速开始</a> ·
24
24
  <a href="#-安装">安装</a> ·
25
- <a href="#-工作流程">工作流程</a>
25
+ <a href="#-工作流程">工作流程</a> ·
26
+ <a href="#%EF%B8%8F-命令行选项">命令行选项</a>
26
27
  </p>
27
28
 
28
29
  <p align="center">
@@ -35,11 +36,18 @@
35
36
 
36
37
  ## ✨ 功能特性
37
38
 
38
- - 🎯 **多选提交** — 使用 Space / Enter 选择不连续的提交进行 cherry-pick
39
+ - 🎯 **多选提交** — 使用 Space 选择不连续的提交,Shift+↑↓ 连选,`a` 全选,`i` 反选
39
40
  - 🔍 **分支搜索** — 按关键词模糊过滤分支
40
- - 👀 **差异预览** — 执行前查看所选提交的 `--stat` 摘要
41
- - ⚡ **安全模式** — `--no-commit` 仅暂存变更供审查,不会自动提交
42
- - ⚠️ **冲突处理** cherry-pick 失败时清晰显示冲突文件
41
+ - 👀 **差异预览** — 可滚动的 `--stat` 摘要面板,支持 `j`/`k` 上下滚动
42
+ - ⚡ **双模式** — `--no-commit` 仅暂存变更供审查,或逐个提交保留原始 commit 信息
43
+ - 🔀 **逐个 cherry-pick** — 按顺序执行提交,遇到冲突时暂停等待交互处理
44
+ - ⚠️ **冲突处理** — 显示冲突文件列表,在另一终端解决后继续/放弃/退出
45
+ - 🛡️ **安全备份** — 执行前自动创建备份分支,放弃时完整回滚
46
+ - 📦 **自动 stash** — 检测未提交变更,提示 stash 保存,同步后自动恢复
47
+ - 🔄 **Stash 恢复** — 检测上次中断的会话,提供恢复 stash 的选项
48
+ - 🌿 **分支检查** — 若当前不在目标分支,自动从 main/master 创建并切换
49
+ - ✅ **已同步标记** — 在 commit 列表中标记已同步的提交为 `[已同步]`
50
+ - 🖥️ **CLI 模式** — 支持 `-r -b -c` 参数的非交互模式,适用于脚本
43
51
  - 🌐 **通用性** — 适用于任何 Git 仓库,不限语言
44
52
 
45
53
  ## 🚀 快速开始
@@ -64,35 +72,95 @@ npm install -g git-sync-tui
64
72
  ## 🔄 工作流程
65
73
 
66
74
  ```
67
- 选择远程仓库 → 选择分支 → 多选提交预览变更
68
-
69
- 手动审查并提交 ← Cherry-pick --no-commit(已暂存,未提交)
75
+ 检查工作区 → 选择远程仓库 → 选择分支 → 分支检查多选提交
76
+
77
+ 自动 stash 预览 diff 统计
78
+ (如需要) ↓
79
+ 确认并选择模式
80
+
81
+ 逐个 cherry-pick(带备份)
82
+
83
+ 处理冲突 / 完成
84
+
85
+ 恢复 stash 并退出
70
86
  ```
71
87
 
72
88
  ## ⌨️ 快捷键
73
89
 
90
+ ### 提交选择
91
+
74
92
  | 按键 | 操作 |
75
93
  |-----|------|
76
94
  | `↑` `↓` | 上下导航 |
77
95
  | `Space` | 切换提交选择 |
96
+ | `Shift`+`↑`/`↓` | 连续选择 |
97
+ | `a` | 全选 / 取消全选 |
98
+ | `i` | 反选 |
99
+ | `r` | 从开头选至光标 |
100
+ | `j` / `k` | 滚动 diff stat 预览 |
78
101
  | `Enter` | 确认选择 |
79
- | `y` / `n` | 确认 / 取消执行 |
80
- | `/` | 搜索(在分支列表中) |
102
+ | `Esc` | 返回上一步 |
81
103
 
82
- ## 📋 同步后操作
104
+ ### 确认面板
105
+
106
+ | 按键 | 操作 |
107
+ |-----|------|
108
+ | `y` | 确认执行 |
109
+ | `n` | 取消 |
110
+ | `c` | 切换提交模式(--no-commit / 逐个提交) |
111
+ | `m` | 切换 `-m 1`(merge commit 时) |
112
+ | `Esc` | 返回 |
83
113
 
84
- 变更已暂存在工作区(未提交)。你可以:
114
+ ### 冲突处理
85
115
 
86
- ```bash
87
- # 查看暂存的变更
88
- git diff --cached
116
+ | 按键 | 操作 |
117
+ |-----|------|
118
+ | `c` | 继续(冲突已解决) |
119
+ | `a` | 放弃(回滚全部变更) |
120
+ | `q` | 退出(保留当前状态) |
89
121
 
90
- # 准备好后提交
91
- git commit -m "sync: 从 feature-branch cherry-pick 提交"
122
+ ## ⚙️ 命令行选项
92
123
 
93
- # 或放弃所有变更
94
- git reset HEAD
95
124
  ```
125
+ 用法
126
+ $ git-sync-tui [options]
127
+
128
+ 选项
129
+ -r, --remote <name> 指定远程仓库名称
130
+ -b, --branch <name> 指定远程分支名称
131
+ -c, --commits <hashes> 指定 commit hash(逗号分隔)
132
+ -n, --count <number> 显示 commit 数量(默认 100)
133
+ -m, --mainline 对 merge commit 使用 -m 1
134
+ -y, --yes 跳过确认直接执行
135
+ --no-stash 跳过 stash 提示
136
+ --list 列出远程分支的 commit 后退出
137
+
138
+ 模式
139
+ 无参数 交互式 TUI 模式
140
+ -r -b --list 列出 commit(纯文本)
141
+ -r -b -c CLI 模式,确认后执行
142
+ -r -b -c --yes CLI 模式,直接执行
143
+ 仅 -r 或 -r -b TUI 模式,跳过已指定步骤
144
+
145
+ 示例
146
+ $ git-sync-tui # TUI 模式
147
+ $ git-sync-tui -r upstream -b main --list # 列出 commits
148
+ $ git-sync-tui -r upstream -b main -c abc1234 --yes # 直接执行
149
+ $ git-sync-tui -r upstream -b main -c abc1234,def5678 # 确认后执行
150
+ $ git-sync-tui -r upstream # TUI 模式,跳过选择仓库
151
+ ```
152
+
153
+ ## 📋 同步后操作
154
+
155
+ **--no-commit 模式** — 变更已暂存在工作区(未提交):
156
+
157
+ ```bash
158
+ git diff --cached # 查看暂存的变更
159
+ git commit -m "sync: 从 feature-branch cherry-pick 提交" # 提交
160
+ git reset HEAD # 或放弃所有变更
161
+ ```
162
+
163
+ **逐个提交模式** — 保留原始 commit 信息,可通过 `git log` 查看。
96
164
 
97
165
  ## 💡 使用场景
98
166
 
@@ -107,8 +175,8 @@ git reset HEAD
107
175
  ```bash
108
176
  git clone https://github.com/KiWi233333/git-sync-tui.git
109
177
  cd git-sync-tui
110
- npm install
111
- npm start
178
+ pnpm install
179
+ pnpm start
112
180
  ```
113
181
 
114
182
  ## 🏗️ 技术栈
@@ -116,6 +184,7 @@ npm start
116
184
  - [Ink](https://github.com/vadimdemedes/ink) — 用于构建交互式 CLI 应用的 React 框架
117
185
  - [@inkjs/ui](https://github.com/inkjs/ui) — Ink 的 UI 组件库
118
186
  - [simple-git](https://github.com/steveukx/git-js) — Git 命令接口
187
+ - [meow](https://github.com/sindresorhus/meow) — CLI 参数解析
119
188
 
120
189
  ## 🤝 贡献
121
190