Skip to content
| Marketplace
Sign in
Visual Studio Code>SCM Providers>MGitSVNNew to Visual Studio Code? Get it now.
MGitSVN

MGitSVN

realguan

|
5 installs
| (1) | Free
Multi-repository git-svn manager for VS Code
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

MGitSVN

多仓库 git-svn 管理器 - VS Code / Windsurf 插件

🎯 解决痛点:微服务项目使用 SVN 托管,但习惯用 Git 方式管理代码。无需完整仓库权限,也能统一管理多个子服务的 git-svn 操作。

功能特性

  • 一键批量操作:同步、拉取、提交所有服务代码
  • 分支管理:跨多仓库统一切换 Git 本地分支
  • SVN 源切换:支持 trunk/branch 切换,适配开发期与封测期
  • Worktree 支持:批量创建/删除 worktree,实现多分支并行开发
  • 状态监控:侧边栏和状态栏实时显示项目状态

工作场景与使用方法

场景一:首次克隆项目代码

背景:刚接手项目,需要从 SVN 拉取多个服务模块的代码。

操作步骤:

  1. 创建工作目录并用编辑器打开

    mkdir -p ~/svn/ms_stac && cd ~/svn/ms_stac
    code .  # 或 windsurf .
    
  2. 初始化配置

    • Cmd+Shift+P → MGitSVN: Initialize Config
    • 确认根目录路径
  3. 编辑 .mgitsvn.json,添加项目配置

    {
      "rootDir": "./",
      "projects": [
        {
          "name": "st_cd",
          "path": "st_cd",
          "svnRemotes": {
            "trunk": "svn://192.168.199.199/svn_home/ms_stac/trunk/st_cd",
            "branch": "svn://192.168.199.199/svn_home/ms_stac/branches/{branch}/st_cd"
          }
        },
        {
          "name": "st_web",
          "path": "st_web",
          "svnRemotes": {
            "trunk": "svn://192.168.199.199/svn_home/ms_stac/trunk/st_web",
            "branch": "svn://192.168.199.199/svn_home/ms_stac/branches/{branch}/st_web"
          }
        }
      ]
    }
    
  4. 批量克隆所有项目

    • 点击侧边栏 Projects 视图的 📥 Clone All 按钮
    • 或 Cmd+Shift+P → MGitSVN: Clone All Projects

场景二:日常开发工作流

背景:每天开始工作前拉取最新代码,开发完成后提交。

操作步骤:

  1. 拉取最新代码

    • 快捷键 Cmd+Shift+R
    • 或点击侧边栏 ⬇️ Rebase All 按钮
    • 等效于对每个项目执行 git svn rebase
  2. 创建开发分支(推荐,避免直接在主分支开发)

    • 点击侧边栏 🔀 Checkout Branch 按钮
    • 选择 "Create new branch..."
    • 输入分支名:feature/my-feature
    • 所有项目会同时创建并切换到该分支
  3. 正常开发

    • 在各项目中修改代码
    • 使用 Git 正常提交(commit)
  4. 合并并提交到 SVN

    # 在每个项目中
    git checkout dev          # 切回主分支
    git merge feature/my-feature  # 合并开发分支
    
    • 然后点击侧边栏 ⬆️ Dcommit All 按钮提交到 SVN
    • 或快捷键 Cmd+Shift+D

场景三:切换到不同的 SVN 分支(开发期 ↔ 封测期)

背景:

  • 开发期:使用 svn://xxx/branches/branch_2.2.0_xxx/ 分支
  • 封测期:需要切换到 svn://xxx/trunk/ 分支

操作步骤:

  1. 点击侧边栏 🖥️ Switch SVN Remote 按钮

  2. 选择目标:

    • trunk:切换到稳定的 trunk 分支
    • branch:切换到开发分支(需要输入分支名,如 branch_2.2.0_20251204)
  3. 插件会自动:

    • 添加对应的 SVN remote 配置
    • 拉取该 remote 的最新代码 (git svn fetch)
    • 创建并切换到对应的本地分支

工作流示意图:

┌─────────────────────────────────────────────────────────────┐
│                      SVN 服务器                             │
│   ┌─────────────┐              ┌─────────────────────┐      │
│   │   trunk     │              │ branches/branch_xxx │      │
│   └──────┬──────┘              └──────────┬──────────┘      │
└──────────│─────────────────────────────────│────────────────┘
           │                                 │
           ▼                                 ▼
┌──────────────────────────────────────────────────────────────┐
│                    本地 Git 仓库                             │
│   ┌─────────────┐              ┌─────────────────────┐      │
│   │ trunk 分支  │              │ branch_xxx 分支     │      │
│   └──────┬──────┘              └──────────┬──────────┘      │
│          │                                 │                 │
│          └──────────┬──────────────────────┘                 │
│                     ▼                                        │
│   ┌─────────────────────────────────────────────────────┐   │
│   │ feature/my-feature 分支 (本地开发用)                │   │
│   └─────────────────────────────────────────────────────┘   │
└──────────────────────────────────────────────────────────────┘

场景四:多分支并行开发(使用 Worktree)

背景:需要同时处理多个功能/版本,频繁切换分支太麻烦。

操作步骤:

  1. 创建 Worktree

    • 点击侧边栏 Worktrees 视图的 ➕ 按钮
    • 输入分支名:feature/login
    • 插件会为所有项目创建 worktree,并生成 VS Code 工作区文件
  2. 打开 Worktree 工作区

    • 在 Worktrees 列表中点击对应项
    • 选择 "Open Worktree"
    • 在新窗口中打开该分支的完整工作区
  3. 删除 Worktree(开发完成后)

    • 右键点击 Worktree → "Remove Worktree"
    • 插件会清理所有相关目录

目录结构:

~/svn/
├── ms_stac/                    ← 主工作区
│   ├── .mgitsvn.json
│   ├── st_cd/
│   └── st_web/
│
├── ms_stac_feature_login/      ← worktree (feature/login 分支)
│   ├── feature_login.code-workspace
│   ├── st_cd/
│   └── st_web/
│
└── ms_stac_hotfix_bug123/      ← worktree (hotfix/bug123 分支)
    ├── hotfix_bug123.code-workspace
    ├── st_cd/
    └── st_web/

场景五:新版本开发(切换到新的 branch)

背景:新版本开发开始,需要从新的 SVN branch 拉取代码。

操作步骤:

  1. 点击 Switch SVN Remote 按钮
  2. 选择 branch
  3. 输入新的分支名:branch_2.3.0_20260101
  4. 插件会自动拉取新分支并创建本地分支

命令列表

命令 快捷键 侧边栏按钮 描述
MGitSVN: Rebase All Cmd+Shift+R ⬇️ 拉取所有仓库最新代码
MGitSVN: Dcommit All Cmd+Shift+D ⬆️ 提交所有仓库变更到 SVN
MGitSVN: Status All Cmd+Shift+S - 查看所有仓库状态
MGitSVN: Checkout Branch - 🔀 切换/创建 Git 本地分支
MGitSVN: Switch SVN Remote - 🖥️ 切换 SVN 源 (trunk/branch)
MGitSVN: Clone All Projects - 📥 批量克隆配置文件中所有项目
MGitSVN: Create Worktree - ➕ 为新分支批量创建 worktree
MGitSVN: Remove Worktree - 🗑️ 批量删除 worktree
MGitSVN: Open Worktree - 📂 在新窗口打开 worktree
MGitSVN: Refresh - 🔄 刷新所有状态
MGitSVN: Initialize Config - - 初始化配置文件

配置文件详解

配置文件 .mgitsvn.json 放在工作区根目录。

完整示例

{
  "rootDir": "./",
  "projects": [
    {
      "name": "st_cd",
      "path": "st_cd",
      "svnRemotes": {
        "trunk": "svn://192.168.1.100/svn_home/ms_stac/trunk/st_cd",
        "branch": "svn://192.168.1.100/svn_home/ms_stac/branches/{branch}/st_cd"
      },
      "enabled": true
    },
    {
      "name": "st_web",
      "path": "st_web",
      "svnRemotes": {
        "trunk": "svn://192.168.1.100/svn_home/ms_stac/trunk/st_web",
        "branch": "svn://192.168.1.100/svn_home/ms_stac/branches/{branch}/st_web"
      },
      "enabled": true
    },
    {
      "name": "st_common",
      "path": "st_common",
      "svnRemotes": {
        "origin": "svn://192.168.1.100/svn_home/ms_stac/trunk/st_common"
      },
      "enabled": true
    }
  ],
  "worktreeBaseDir": "../"
}

字段说明

字段 类型 必填 说明
rootDir string ✅ 项目根目录,支持相对路径(相对于配置文件)
projects array ✅ 子项目列表
worktreeBaseDir string ❌ worktree 存放目录,默认为 rootDir 的父目录

project 配置

字段 类型 必填 说明
name string ✅ 项目显示名称
path string ✅ 相对于 rootDir 的路径
svnRemotes object ❌ 多 SVN 源配置,支持 {branch} 模板
enabled boolean ❌ 是否启用,默认 true

svnRemotes 模板说明

  • trunk: 固定 URL,如 svn://xxx/trunk/st_cd
  • branch: 可使用 {branch} 占位符,运行时会提示输入分支名替换

VS Code 设置

配置项 类型 默认值 描述
mgitsvn.concurrency number 3 并发操作数
mgitsvn.autoRefresh boolean true 操作后自动刷新
mgitsvn.showNotifications boolean true 显示操作结果通知

界面说明

侧边栏 Projects

  • ✅ 绿色:代码已同步,无未提交变更
  • ⚠️ 黄色:有未提交的变更
  • ❌ 红色:存在冲突

状态栏

格式:[同步数/总数] | [分支名] [变更数]

示例:3/5 | dev ✎2 表示 5 个项目中 3 个已同步,当前分支 dev,共 2 个文件变更。


安装

从 VSIX 安装

# VS Code
code --install-extension mgitsvn-0.0.1.vsix

# Windsurf
windsurf --install-extension mgitsvn-0.0.1.vsix

开发模式

cd mgitsvn
pnpm install
pnpm run compile
# 按 F5 启动调试

常见问题

Q: 命令提示 "command not found"

A: 插件未正确激活。请:

  1. 重启编辑器
  2. 确保已打开包含 .mgitsvn.json 的文件夹
  3. 查看开发者工具 (Cmd+Shift+P → Developer Tools) 检查错误

Q: Switch SVN Remote 提示 "No SVN remotes configured"

A: 需要在 .mgitsvn.json 中配置 svnRemotes:

{
  "svnRemotes": {
    "trunk": "svn://xxx/trunk/project",
    "branch": "svn://xxx/branches/{branch}/project"
  }
}

Q: Clone 卡住不动

A: 可能是网络问题或 SVN 服务器响应慢。插件默认使用 -r HEAD 只拉取最新版本,如果仍然很慢,请检查网络连接。


License

MIT

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
© 2026 Microsoft