外部的git checkout分支 [英] git checkout branch from outside
问题描述
问题:我需要以某种方式检出已经在我的文件系统上本地克隆的项目的现有分支,而不在该项目的特定文件夹中。解决方案:我正在尝试执行以下操作:
- git clone'github-project-url''file-system-folder'
- git checkout'existing-branch''file-system-folder'
第二步是不正确的,但我也试图避免cd文件系统文件夹。
<您可以使用 - git-dir
来指定 .git
目录作为存储库,而 - work-tree
来指定工作树来结帐。请参阅 git
手册页以获得详细信息。
git --git-dir =文件系统文件夹/ .git --work-tree = file-system-fo lder结账现有分支
Problem: I need somehow to checkout an existing branch of a project that is already cloned locally on my file system without being in that particular folder of this project.
Solution: I'm trying to do the following:
- git clone 'github-project-url' 'file-system-folder'
- git checkout 'existing-branch' 'file-system-folder'
I do realize that second step is not quite right, but I also am trying to avoid to "cd 'file-system-folder'".
You can use --git-dir
to specify the .git
directory to use as the repository, and --work-tree
to specify the working tree to to the checkout in. See the git
man page for details.
git --git-dir=file-system-folder/.git --work-tree=file-system-folder checkout existing-branch
这篇关于外部的git checkout分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!