Git tutorial: Understanding git pull and branches (using a specific example repo)

久未见 提交于 2019-12-24 07:00:12

问题


Backround:

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)

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.

Questions:

  1. 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?
  2. 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?
  3. 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)?

回答1:


  1. 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 with git branch localname origin/remotename
  2. No.
  3. A multi-step process, which I suggest you don't bother with (create repository, set up a remote, do partial fetches of the remote).


来源:https://stackoverflow.com/questions/2807098/git-tutorial-understanding-git-pull-and-branches-using-a-specific-example-repo

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!