从GitHub克隆Git之后,我看不到我的分支 [英] After Git clone from GitHub, I do not see my branch

查看:989
本文介绍了从GitHub克隆Git之后,我看不到我的分支的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在GitHub上有一个存储库.它包含master和一个分支.

I have a repository on GitHub. It contains master and one branch.

当我克隆它时,我仅获得master而看不到我的分支.

When I clone it, I obtain only master and do not see my branch.

为什么会这样?如何查看存储库中的所有分支?

Why is it so? How can I see all branches in the repository?

推荐答案

默认情况下,git clone仅创建一个分支:当前签出的分支,通常是主分支.但是,它确实为远程中的所有其他分支创建了远程跟踪分支.可以将它们视为远程分支的本地副本,可以通过获取来更新它们.它们不是真正的本地分支,因为它们仅用作指向远程分支所在位置的指针,而不是供您使用.

By default, git clone creates only one branch: the currently checked out one, generally master. However, it does create remote tracking branches for all other branches in the remote. Think of these as local copies of the remote's branches, which can be updated by fetching. They're not real local branches, as they're intended only as pointers to where the remote's branches are, not for you to work on.

如果运行git branch -a,您将看到所有本地和远程分支.如果只想看远程的,请使用git branch -r.如果您希望显示视觉历史记录,请尝试gitk --all(或gitk --remotes).

If you run git branch -a you'll see all branches, local and remote. If you want to see just the remote ones, use git branch -r. If you prefer a visual history display, try gitk --all (or gitk --remotes).

要创建要处理的本地分支,请使用

To create a local branch to work on, use

git branch <branch-name> origin/<branch-name>

这将以远程分支为起点创建一个新的本地分支.

That'll create a new local branch using the remote's branch as the starting point.

这篇关于从GitHub克隆Git之后,我看不到我的分支的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆