実行前の状態
main ブランチで README.md を
このgit branch hotfix は、
ターミナル
git init -q -b main hello
cd hello
echo "# hello" > README.md
git add README.md
git commit -q -m "README を作る"
git branch hotfix
echo "書きかけ" >> README.md最小の例と結果
開きたい
ターミナル
git worktree add ../hello-hotfix hotfixPreparing worktree (checking out 'hotfix')
HEAD is now at a1b2c3d README を作る../hello-hotfix は、
成功の確認
別のgit branch で + が
ターミナル
git branch+ hotfix
* mainターミナル
git -C ../hello-hotfix branch --show-currenthotfixターミナル
git status -s M README.md最後の* は、
構文と 主要オプション
| 書き方 | すること |
|---|---|
git worktree add <フォルダ> <ブランチ名> | 既に |
git worktree add -b <新しい名前> <フォルダ> | 新しい |
git worktree list | 開いている |
git worktree remove <フォルダ> | フォルダを |
git worktree prune | フォルダを |
失敗時の戻し方
同じ
main をgit worktree add -b で
フォルダを閉じるとき
作業がgit worktree remove ../hello-hotfix を--force を
フォルダを Finder や
登録のgit worktree prune で
よくある疑問
clone し直すのとは 何が 違いますか
worktree は、
作った フォルダに node_modules は ありますか
ありません。
stash と どちらを 使いますか
すぐ
