[英]How to change head location to another folder?
My master branch is currently syncing with a local folder W:\\folder2
. 我的master分支当前正在与本地文件夹
W:\\folder2
同步。
I'd like my master branch to sync with local folder W:\\folder1
instead. 我希望我的master分支改为与本地文件夹
W:\\folder1
同步。
How can I do this? 我怎样才能做到这一点?
I was playing around, while learning, in GitShell with git worktree add <second path>
and git checkout master
and git checkout -b <new branch>
commands. 在学习的同时,我正在GitShell中使用
git worktree add <second path>
和git checkout master
以及git checkout -b <new branch>
命令。
Before, my master branch was synced with local folder W:\\folder1
. 以前,我的master分支已与本地文件夹
W:\\folder1
同步。
Now it's synced with local folder W:\\folder2
. 现在,它已与本地文件夹
W:\\folder2
同步。
I think I accidentally switched something. 我想我不小心换了东西。
How do I switch it back? 如何切换回去?
git worktree
Git worktree was introduced in 2007 under the contrib
folder in git repo and was called new-workdir
. Git工作树于2007年在git repo中的
contrib
文件夹下引入,并称为new-workdir
。
In git V2.5 it was named worktree
and it allow you to have multiple instances of the same repository across different folders. 在git V2.5中,它被称为工作
worktree
,它使您可以在不同文件夹中拥有同一存储库的多个实例。
for example: 例如:
git worktree add <second path>
will create another folder on your computer which allow you to work on different branch simultaneously. 将在您的计算机上创建另一个文件夹,使您可以同时在不同的分支上工作。
If you want to remove the worktree use the prune subcommand 如果要删除工作树,请使用prune子命令
prune
Prune working tree information in $GIT_DIR/worktrees.在$ GIT_DIR / worktrees中修剪工作树信息。
Another option to remove it is to delete the .git/worktrees
folder 删除它的另一种方法是删除
.git/worktrees
文件夹
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.