GIT 拉取或克隆存储库仅获取 Master 分支

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13204910/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-10 14:52:14  来源:igfitidea点击:

GIT pulling or cloning repository only gets Master branch

gitclonebitbucketpull

提问by JohnA

I host on BitBucket when I git clonea repository or use git pull origin masterand git pull origin myBranchit does pull second time, but when I list branches with git branch -vI only see master. Doing git statusshows nothing too.

我在git clone存储库或使用时托管在 BitBucket 上git pull origin mastergit pull origin myBranch它确实第二次拉取,但是当我列出分支时,git branch -v我只看到master。做git status也什么也看不出来。

How do I pull all of the branches off the web repo to my local repo?

如何将所有分支从 Web 存储库拉到我的本地存储库?

Could it be that it's because I changed computers and name on the git settings changed so it only lets me get mastersince it's the default branch and the other one can be only accessed by whoever created it?

可能是因为我更改了计算机并且更改了 git 设置上的名称,所以它只能让我获得,master因为它是默认分支,而另一个只能由创建它的人访问?

回答by Michael Durrant

Try using this:

尝试使用这个:

git branch -a

You'll see the list of remote branches in origin/ e.g.

您将在 origin/ 中看到远程分支列表,例如

Output:

输出:

remotes/origin/tk_removes_call_centers
remotes/origin/tk_warm_transfer_fix
remotes/origin/update_README

and you can then

然后你可以

git checkout [any_individual_branch_name]

You can also get the same list with git branch -v --allwhich includes the most recent commit info, i.e.

您还可以获得git branch -v --all包含最新提交信息的相同列表,即

git branch -v --all

output:

输出:

remotes/origin/tk_removes_call_centers     1478b14 re-adding call feedback workers
remotes/origin/tk_warm_transfer_fix        94720c5 handling blank auto policy
remotes/origin/update_README               a769b82 Update README

git branch -v(without --all) only shows branches you've worked on. When you use --allyou see allthe tracking branches in origin/

git branch -v(没有--all) 只显示你工作过的分支。当您使用时,--all您会看到所有跟踪分支origin/

Related:
- How to clone all remote branches in Git?
- How do you create a remote Git branch?
- Git fetch remote branch
- How do I check out a remote Git branch?

相关:
-如何在 Git 中克隆所有远程分支?
-如何创建远程 Git 分支?
- Git 获取远程分支
-如何检出远程 Git 分支?

回答by Karthik damodara

Do this list of commands:

执行以下命令列表:

git branch -a:

git 分支 -a

you will see the list of remote branches

您将看到远程分支列表

git remote show origin

git远程显示原点

It will display all branches known by your local repository. If the branch you want to use is not in the list, run the command

它将显示本地存储库已知的所有分支。如果您要使用的分支不在列表中,请运行命令

git remote update

git远程更新

which updates the entire list of remote branches tracked by your local repository and then run

它更新本地存储库跟踪的远程分支的整个列表,然后运行

git fetch

混帐

which updates all tracked branches.

它更新所有跟踪的分支。

Then you can create your branch with the following checkout command:

然后您可以使用以下 checkout 命令创建您的分支:

git checkout -b your_branch_local_name origin/your_branch_remote_name

git checkout -b your_branch_local_name origin/your_branch_remote_name