Git教程:了解git pull和branchs(使用特定的示例存储库) [英] Git tutorial: Understanding git pull and branches (using a specific example repo)
本文介绍了Git教程:了解git pull和branchs(使用特定的示例存储库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
背景:
假设我有以下Git URL(托管在github上)
Suppose I have the following Git URLs (hosted on github)
http://github.com/mikl/drupal.git
git://github.com/mikl/drupal.git (Git read-only)
我对此存储库的本地副本感兴趣,因此我可以在git中处理分支并进行实践
I am interested in having a local copy of this repository so I can pratice working with branches in git and see how my local working tree can change depending on which branch I am working with.
问题:
- 首先,我建立一个本地目录并执行git clone git://github.com/mikl/drupal.git ...该克隆 all 的分支?还是只克隆主人?
- github的Web前端为我提供了一个下拉菜单,该菜单允许我切换分支...更改此下拉菜单实际上是否会更改当我运行git clone时,我将抓住哪个分支?
- 如果我想在本地计算机上获得该存储库的新副本,但是我只对这个存储库的两个分支感兴趣,我想忽略所有其余的内容,我该使用什么命令来确保仅克隆这两个分支,而不克隆其他任何分支(假设其中一个分支是master)?
- To get started, I set up a local directory and do git clone git://github.com/mikl/drupal.git ... Will this clone all of the branches? Or will it only clone master?
- The web front-end for github gives me a "drop down" menu that allows me to switch branches ... Does changing this drop-down actually change which branch I will be grabbing when I run git clone?
- If I want a new copy of this repository on my local machine, but I am interested in only two branches of this repository and I want to ignore all the rest, what command do I use to ensure I clone only those two branches and nothing else (assume one of the branches is master)?
推荐答案
- 它将克隆所有分支。但是,除了master之外,不会为任何其他对象创建本地分支。您可以使用
git branch -r
查看远程分支,并使用git branch localname origin / remotename
创建本地跟踪分支。 - 否。
- 一个多步骤过程,建议您不要打扰(创建存储库,设置远程服务器,执行部分操作
- It will clone all of the branches. However, there will be no local branches created for anything but master. You can view the remote branches with
git branch -r
and create a local tracking branch withgit branch localname origin/remotename
- No.
- A multi-step process, which I suggest you don't bother with (create repository, set up a remote, do partial fetches of the remote).
这篇关于Git教程:了解git pull和branchs(使用特定的示例存储库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文