外部的git checkout分支 [英] git checkout branch from outside

查看:89
本文介绍了外部的git checkout分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



问题:我需要以某种方式检出已经在我的文件系统上本地克隆的项目的现有分支,而不在该项目的特定文件夹中。解决方案:我正在尝试执行以下操作:


  1. git clone'github-project-url''file-system-folder'

  2. 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:

  1. git clone 'github-project-url' 'file-system-folder'
  2. 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆