git 如何拉出 SourceTree 中的所有分支?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32577557/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I pull all branches in SourceTree?
提问by Harrison Xi
I didn't see any options to do this in the pull window. What should I do?
我在拉窗口中没有看到任何执行此操作的选项。我该怎么办?
采纳答案by Aaron Brager
When the repository is cloned, you will see all of the remote branches under "Remotes" in the Sidebar.
克隆存储库后,您将在侧栏中的“远程”下看到所有远程分支。
If any content is missing, you can click Fetchto fetch all objects necessary to complete the history for all branches and tags in the remote repository.
如果缺少任何内容,您可以单击获取以获取完成远程存储库中所有分支和标签的历史记录所需的所有对象。
If you can see it in SourceTree, it's stored on your computer. If you want to check out one of the branches, double click it. You can switch to any of the branches whenever you want without an Internet connection.
如果您可以在 SourceTree 中看到它,则它存储在您的计算机上。如果您想签出其中一个分支,请双击它。您可以在没有 Internet 连接的情况下随时切换到任何分支机构。
There is no way to — and no need to — "pull all branches".
没有办法——也没有必要——“拉出所有分支”。
回答by Nate Cook
I would like to expand on the other answers.
我想扩展其他答案。
With git, first you have to checkout the remote branches that you are interested in, so that they are local. So in SourceTree you right click on each remote branch and click checkout.
使用 git,首先您必须检出您感兴趣的远程分支,以便它们是本地的。因此,在 SourceTree 中,您右键单击每个远程分支并单击结帐。
Once the branches in which you are interested are local, you can now use git-up.
一旦您感兴趣的分支是本地的,您现在可以使用 git-up。
How to install git-up so it is easy to use in SourceTree
如何安装 git-up 以便在 SourceTree 中使用
For me on OSX 10.11.1 (El Capitan) it was as simple as sudo gem install git-up
in Terminal, but YMMV. (Make sure the git-up executable it installs is in your path. For me it was installed to /usr/local/bin
which was already in my path. Google if you need help with that. Hereis a Stack Overflow link that might help.)
对于 OSX 10.11.1 (El Capitan) 上的我来说,它和sudo gem install git-up
终端一样简单,但是 YMMV。(确保它安装的 git-up 可执行文件在您的路径中。对我来说,它已安装到/usr/local/bin
我的路径中。如果您需要帮助,请谷歌。这是一个 Stack Overflow 链接,可能会有所帮助。)
Now create a custom action in SourceTree. Go to SourceTree preferences -> Custom Actions and click add. Fill out as follows:
现在在 SourceTree 中创建一个自定义操作。转到 SourceTree 首选项 -> 自定义操作,然后单击添加。填写如下:
- Menu Caption:
git-up
- Script to run:
git-up
- Show Full Output: checked (my personal preference, unchecked is also ok)
- Parameters: leave blank
- Click "click to record shortcut" and assign a keyboard shortcut. (I use
CMD + U
.)
- 菜单标题:
git-up
- 要运行的脚本:
git-up
- 显示完整输出:选中(我个人喜好,不选中也可以)
- 参数:留空
- 单击“单击以记录快捷方式”并分配键盘快捷方式。(我用
CMD + U
。)
Now whenever you are in SourceTree use your keyboard shorcut to pull/rebase all of your checked out branches. This prevents you from having to switch to each branch to pull/rebase each branch.
现在,无论何时您在 SourceTree 中,都可以使用键盘快捷键来拉/重新设定所有检出的分支。这可以防止您必须切换到每个分支来拉/变基每个分支。
Note: if you don't want to rebase you can tweak exactly what git-up does. See git-up's github page.
注意:如果你不想变基,你可以精确地调整 git-up 的作用。参见git-up 的 github 页面。
回答by Gorodeckij Dimitrij
Connect SourceTree to master (clone)
将 SourceTree 连接到 master(克隆)
Then with shell navigate to project folder and run such:
然后使用 shell 导航到项目文件夹并运行:
git branch -r
(will show all remote branches)
git branch -r
(将显示所有远程分支)
git checkout --track origin/[branch name]
git checkout --track origin/[branch name]
repeat checkout for all branches - SourceTree will get them almost immediately
对所有分支重复结帐 - SourceTree 几乎会立即获取它们