Workflow ini pakai git worktree — fitur git yang bikin kamu bisa checkout beberapa branch sekaligus di folder yang berbeda, tanpa perlu clone ulang repo.
Masalah yang Diselesaikan
Biasanya kalau mau switch branch:
git stash
git checkout feat-xxx
# kerja...
git checkout master
git stash popRibet. Kalau lagi di tengah-tengah dev satu fitur, terpaksa stop dulu.
Dengan worktree: tiap branch punya folder sendiri. Bisa buka semua sekaligus.
Konsep
ALL-OBSIDIAN-PLUGIN/ ← folder utama (branch: master)
ALL-OBSIDIAN-PLUGIN-symlink/ ← worktree (branch: feat-symlink-manager)
ALL-OBSIDIAN-PLUGIN-table/ ← worktree (branch: feat-convert-table-to-files)
ALL-OBSIDIAN-PLUGIN-xyz/ ← worktree (branch: feat-xyz)
Satu repo, banyak folder, banyak branch — jalan bersamaan.
Setup Awal
Struktur folder yang direkomendasikan
E:\
└── plugins\
├── ALL-OBSIDIAN-PLUGIN\ ← main repo (clone di sini)
├── ALL-OBSIDIAN-PLUGIN-symlink\ ← worktree
└── ALL-OBSIDIAN-PLUGIN-table\ ← worktree
Clone main repo (sekali saja)
git clone https://github.com/pakcli/ALL-OBSIDIAN-PLUGIN.git
cd ALL-OBSIDIAN-PLUGINCara Pakai
Tambah worktree untuk branch yang sudah ada
git worktree add ../All-Obsidian-Plugin-symlink feat-symlink-manager
git worktree add ../All-Obsidian-Plugin-table feat-convert-table-to-files
git worktree add ../All-Obsidian-Plugin-circuitjs feat-circuitjs
git worktree add ../All-Obsidian-Plugin-tree feat-tree-interactive
git worktree add ../ALL-OBSIDIAN-PLUGIN-python-excecutor -b feat-python-excecutor
git worktree add ../PluginObsidian-custom-graph-view -b feat-custom-graph-viewgit worktree add ../PluginObsidian-custom-graph-view feat-custom-graph-view
git worktree add ../PluginObsidian-assets-router feat-assets-router
git worktree add ../PluginObsidian-symlink-manager feat-symlink-manager
git worktree add ../PluginObsidian-readme-md-manager feat-readme-md-manager
git worktree add ../PluginObsidian-csv-editor -b feat-csv-editor
git worktree add ../PluginObsidian-onpage-data-csv -b feat-onpage-data-csv
git worktree add ../PluginObsidian-gdrive-files-browser feat-gdrive-files-browser
git worktree add ../PluginObsidian-webview-spliter -b feat-webview-spliter
git worktree add ../PluginObsidian-tree-interactive feat-tree-interactive
git worktree add ../PluginObsidian-custom-graph-view feat-custom-graph-view 2>/dev/null || (rm -rf ../PluginObsidian-custom-graph-view && git worktree add ../PluginObsidian-custom-graph-view feat-custom-graph-view)
Tambah worktree + buat branch baru sekaligus
git worktree add ../ALL-OBSIDIAN-PLUGIN-newfeature -b feat-new-featureLihat semua worktree aktif
git worktree listOutput:
E:/plugins/ALL-OBSIDIAN-PLUGIN 47c626e [master]
E:/plugins/ALL-OBSIDIAN-PLUGIN-symlink abc1234 [feat-symlink-manager]
E:/plugins/ALL-OBSIDIAN-PLUGIN-table 570da77 [feat-convert-table-to-files]
Workflow Harian
Mau kerja di fitur symlink
cd E:\plugins\ALL-OBSIDIAN-PLUGIN-symlink
# langsung kerja, sudah di branch feat-symlink-manager
code .Mau kerja di fitur table
cd E:\plugins\ALL-OBSIDIAN-PLUGIN-table
# langsung kerja, sudah di branch feat-convert-table-to-files
code .Mau update master dan sync ke semua worktree
# di folder main
cd E:\plugins\ALL-OBSIDIAN-PLUGIN
git pull origin master
# di masing-masing worktree, rebase/merge dari master
cd E:\plugins\ALL-OBSIDIAN-PLUGIN-symlink
git rebase master
# atau
git merge masterPush & PR
Sama seperti biasa, dari folder worktree masing-masing:
cd E:\plugins\ALL-OBSIDIAN-PLUGIN-table
git add .
git commit -m "feat: ..."
git push origin feat-convert-table-to-filesHapus Worktree (setelah branch di-merge)
# hapus folder worktree
git worktree remove ../ALL-OBSIDIAN-PLUGIN-table
# atau force kalau ada perubahan belum di-commit
git worktree remove --force ../ALL-OBSIDIAN-PLUGIN-table
# cleanup referensi lama
git worktree pruneRules & Batasan
| Rule | Keterangan |
|---|---|
| 1 branch = 1 worktree | Branch yang sama tidak bisa di-checkout di 2 folder |
node_modules tidak share | Tiap worktree perlu npm install sendiri |
.git tetap 1 | Semua worktree share repo yang sama |
| Commit dari mana saja | Bisa commit/push dari folder worktree mana pun |
Tips
- Penamaan folder konsisten:
REPO-NAME-branchnamebiar gampang identify - npm install di tiap worktree baru sebelum dev
- Jangan checkout branch yang sama di 2 worktree — git akan error
- Worktree cocok buat hotfix — bisa fix master sambil tetap di tengah-tengah dev fitur
Quick Reference
# tambah worktree
git worktree add <path> <branch>
# tambah worktree + branch baru
git worktree add <path> -b <new-branch>
# lihat semua worktree
git worktree list
# hapus worktree
git worktree remove <path>
# cleanup
git worktree pruneStruktur Folder Gua (Contoh Nyata)
E:\plugins\
├── ALL-OBSIDIAN-PLUGIN\ → master
├── ALL-OBSIDIAN-PLUGIN-symlink\ → feat-symlink-manager
└── ALL-OBSIDIAN-PLUGIN-table\ → feat-convert-table-to-files
Tiap folder bisa dibuka di VS Code secara terpisah, jalan barengan, tanpa ganggu satu sama lain.