← スキル一覧に戻る

using-git-worktrees
by tmitchel2
A source to source algorithmic differentiation library
⭐ 0🍴 0📅 2026年1月24日
SKILL.md
name: using-git-worktrees description: You are an expert user of git worktrees. You interact with git worktrees to implement tasks.
Using Git Worktrees Skill
This skill guides interaction with git worktrees, you will you the git cli for working with worktrees.
Reference help for 'git worktree' command
git worktree add [-f] [--detach] [--checkout] [--lock [--reason <string>]]
[-b <new-branch>] <path> [<commit-ish>]
or: git worktree list [-v | --porcelain [-z]]
or: git worktree lock [--reason <string>] <worktree>
or: git worktree move <worktree> <new-path>
or: git worktree prune [-n] [-v] [--expire <expire>]
or: git worktree remove [-f] <worktree>
or: git worktree repair [<path>...]
or: git worktree unlock <worktree>
IMPORTANT Using A Git Worktree with Submodules
There are some important considerations when using a git worktree with a project that has submodules:
How They Work Together
- Submodules are repository-wide: Submodules are tracked in the main repository's .git/modules/ directory, which is shared across all worktrees. This means all worktrees see the same submodule repositories.
- Each worktree can check out different submodule commits: While the submodule repositories themselves are shared, each worktree can have the submodule checked out at different commits, just like any other file in the repository.
- Initialization required per worktree: When you create a new worktree, you'll need to run git submodule update --init in that worktree to populate the submodule directories.
Common Workflow
- Create a new worktree (e.g. git worktree add ../my-worktree branch-name)
- Navigate to the new worktree (e.g. cd ../my-worktree)
- Initialize and update submodules (e.g. git submodule update --init --recursive)
Potential Issues
- Detached HEAD states: Submodules in worktrees can sometimes end up in detached HEAD states, requiring manual checkout
- Nested worktrees: You cannot create a worktree inside a submodule's directory
- Update carefully: When updating submodules, be aware that changes affect the shared submodule repository.
Using Git Worktrees Workflow
- Create the worktree.
- Navigate to the worktree folder.
- Check for the usage of git submodules by checking for a .gitmodules file.
- Initialize and update submodules.
Using Git Worktrees Notes
- Executing scripts in a git worktree may require one "cd" before calling the script and then another "cd" after to return to the original directory. E.g. cd /private/tmp/claude/graphlessdb-issue-164 && git pull origin main && cd /users/blah/github/graphlessdb. Put another way you will need to cd into the worktree folder before each execution of a script and then you will need to cd back to the original folder to reset the pwd back to what it was before.
- Check for existing branches before creating one. Use
git worktree add <path> <existing-branch>if branch exists, not -b flag - Create new git worktrees under the folder /tmp/claude/.
スコア
総合スコア
40/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です