我有一个项目托管在GitHub上。我在一台计算机上创建了一个分支,然后将我的更改推到GitHub:

git push origin branch-name

现在我在另一台计算机上,我想下载那个分支。所以我试着:

git pull origin branch-name

...但这一切都是覆盖我的主分支与我的新分支的变化。

我需要做什么才能正确地拉出我的远程分支,而不覆盖现有的分支?


当前回答

创建一个新目录,然后做一个克隆。

Git克隆(源地址)(分支名称)

其他回答

创建一个新目录,然后做一个克隆。

Git克隆(源地址)(分支名称)

Git checkout -b branch/name

Git拉源码分支/名称

你可以像这样使用git远程:

git fetch origin

然后设置一个本地分支来跟踪远程分支,如下所示:

git branch --track [local-branch-name] origin/remote-branch-name

现在远程github分支的内容在local-branch-name中。

你可以切换到local-branch-name并开始工作:

git checkout [local-branch-name]

在repo名称中复制Git和cd:

$ git clone https://github.com/PabloEzequiel/iOS-AppleWach.git
Cloning into 'iOS-AppleWach'...
$ cd iOS-AppleWach

切换到我想要的分支(GitHub页面):

$ git checkout -b gh-pages origin/gh-pages
Branch gh-pages set up to track remote branch gh-pages from origin.
Switched to a new branch 'gh-pages'

拉树枝:

$ git pull
Already up-to-date.

ls:

$ ls
index.html      params.json     stylesheets

我们可以使用以下神奇的命令来下载指定的分支:

git clone -b < branch name > <remote_repo url>