[英]When I clone from github remote repo, which branch of remote repo is cloned to local repo?
I cloned from a certain remote github repo. 我从某个远程github仓库克隆了。
After that, I did not change anything to my local repository, but when I type git status, there shows some modified( or deleted) files. 之后,我没有对本地存储库进行任何更改,但是当我输入git status时,会显示一些已修改(或已删除)的文件。
Here are my questions. 这是我的问题。
When I clone from github remote repo, which branch among remote github repo that my local repository will get or sync to? 当我从github远程存储库克隆时,本地存储库将获取或同步到的远程github存储库中的哪个分支?
If I want to clone certain branch of remote repo to my local repo, how should I do? 如果我想将远程仓库的某些分支克隆到本地仓库,该怎么办?
Thanks 谢谢
With Git (as with any DVCS) you have a whole standalone copy of the full repository locally. 使用Git(与任何DVCS一样),您可以在本地拥有完整存储库的完整独立副本。 (Except if you do a shallow clone, or change the refspec so that only specific branches are cloned).
(除非您进行浅层克隆,或更改refspec以便仅克隆特定分支)。
git clone
creates a local branch for the remote branch that is the default branch for that repository ( HEAD
in the remote points to it) which most often is master
as it is the conventional default. git clone
为远程分支创建一个本地分支,该分支是该存储库的默认分支(在远程指向它的HEAD
),因为它是常规的默认设置,因此通常是master
分支。
If you don't want the default branch created, you can tell git clone
via parameter which branch to create locally after cloning. 如果您不想创建默认分支,可以通过参数告诉
git clone
后在本地创建哪个分支。
Either way you can at any time create local branches from any remote branch you want and name them however you want. 无论哪种方式,您都可以随时从所需的任何远程分支中创建本地分支,并根据需要命名它们。 All remote branches are in your local repository as remote tracking branches, you just do not have local branches for them by default.
所有远程分支都作为远程跟踪分支位于本地存储库中,默认情况下,您只是没有本地分支。
That there are deleted files shown directly after a clone is nearly impossible as to my knowledge. 据我所知,克隆后直接显示删除的文件几乎是不可能的。 Modified files could possibly be shown if you clone to Windows and there is some line-ending mangling going on.
如果您克隆到Windows并且正在进行一些行尾修饰,则可能会显示修改后的文件。 But deleted files should not be possible without you deleting the files.
但是,如果不删除文件,则无法删除文件。
It could be that there are filemode differences. 可能存在文件模式差异。 This sometimes happens when files are stored in the remote from a Linux type of file system and cloned into a Windows file system.
当文件从Linux类型的文件系统存储在远程文件中并克隆到Windows文件系统中时,有时会发生这种情况。
There is some discussion of handling file mode differences here: https://stackoverflow.com/a/1580644/7275012 这里有一些处理文件模式差异的讨论: https : //stackoverflow.com/a/1580644/7275012
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.