简体   繁体   English

如何在特定分支签出的源树中浏览代码

[英]How to browse code in source tree checked out at particular branch

在特定分支或提交中检出source tree ,如何浏览source tree文件,而不会影响原始存储库中的任何内容

You can use git worktree to checkout the content of the other ranch into a new folder without affecting the current branch. 您可以使用git worktree将另一个牧场的内容签出到文件夹中,而不会影响当前分支。

git worktree

git worktree and it allows you to have multiple instances of the same repository across different folders. git worktree ,它允许您在不同文件夹中拥有同一存储库的多个实例。

The wokrtree create new folder with the content of the desired branch but your 3-states will be clean and you will have new 3-states per working folder. wokrtree用所需分支的内容创建新文件夹 ,但是您的3状态将是干净的,每个工作文件夹将具有新的3状态。

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文件夹

在此处输入图片说明


If you use rebase later on: 如果稍后使用rebase:

  • Note: ( Since Git 2.7 ) 注意:( 自Git 2.7起
    you can also use the git rebase [--no]-autostash as well. 您还可以使用git rebase [--no]-autostash

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM