Appearance
Worktree
初始化代码仓库。
git init test
cd test
echo 'Hello World' > hello.txt
git add .
git commit -m 'Initial commit'Initialized empty Git repository in ~/test/.git/
[master (root-commit) *******] Initial commit
1 file changed, 1 insertion(+)
create mode 100644 hello.txt创建分支,创建 worktree。
git branch feature-a
git worktree add ../feature-a feature-a
cd ../feature-a
echo 'Hello Human' > a.txt
git add .
git commit -m 'Add a.txt'Preparing worktree (checking out 'feature-a')
HEAD is now at ******* Initial commit
[feature-a *******] Add a.txt
1 file changed, 1 insertion(+)
create mode 100644 a.txt在原目录切换分支 feature-a ,报错 fatal: 'feature-a' is already used by worktree at **** 。
原目录删除 worktree 。
git worktree remove ../feature-a