@supos-ce-platform/git-tools
Version:
Supos ce platform Git tools, supos, ce, platform, git tools
92 lines (67 loc) • 2.65 kB
Markdown
这是一个用于处理git merge相关操作的工具包,专门为monorepo项目设计。
- 分支合并管理
- 跨仓库分支合并
- 远程分支直接合并
- 冲突解决辅助
- 合并历史查看
- 合并撤销操作
```bash
pnpm add @supos-ce-platform/git-tools
npm -g install @supos-ce-platform/git-tools
```
```typescript
import { GitMergeTools } from '@supos-ce-platform/git-tools';
// 初始化工具实例
const gitTools = new GitMergeTools('/path/to/repo');
// 合并分支
await gitTools.mergeBranch('feature', 'main');
```
```typescript
import { MultiRepoMerge } from '@supos-ce-platform/git-tools';
// 初始化工具实例
const multiRepoMerge = new MultiRepoMerge();
// 合并远程分支(优化版本)
await multiRepoMerge.mergeRemoteBranches(
'source-repo', // 源仓库名称
'feature-branch', // 源分支名称
'target-repo', // 目标仓库名称
'main', // 目标分支名称
{
showDiff: true, // 显示将要合并的差异
conflictStrategy: 'ours', // 冲突解决策略:'ours'使用我们的更改,'theirs'使用他们的更改
push: true // 是否推送合并结果
}
);
```
合并源分支到目标分支
中止当前的合并操作
使用指定策略解决冲突
合并两个远程分支,更专注于远程分支合并,减少了本地分支操作
**参数:**
- `sourceRepo`: 源仓库名称
- `sourceBranch`: 源分支名称
- `targetRepo`: 目标仓库名称
- `targetBranch`: 目标分支名称
- `options`: 合并选项
- `showDiff`: 是否在合并前显示差异
- `conflictStrategy`: 合并冲突时的自动解决策略 ('ours' | 'theirs')
- `push`: 是否推送合并结果
跨仓库合并分支(原始方法)
中止指定仓库的合并操作
使用指定策略解决指定仓库的冲突