简体   繁体   English

当我从github远程仓库克隆时,远程仓库的哪个分支被克隆到本地仓库?

[英]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. 这是我的问题。

  1. When I clone from github remote repo, which branch among remote github repo that my local repository will get or sync to? 当我从github远程存储库克隆时,本地存储库将获取或同步到的远程github存储库中的哪个分支?

  2. 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.

相关问题 克隆本地git repo,就像我从其远程克隆一样 - Clone a local git repo as if I had cloned from its remote 无法从远程github提取克隆的仓库 - Cannot pull cloned repo from remote github 目前尚不存在如何从派生存储库到本地的远程分支以及从中推送分支的当前派生存储库的方式 - How to fetch a remote branch from forked repo to local, and currently forked repo from which branch is pushed is not exist 使用git clone --depth 1克隆repo后,如何获取远程分支 - How do fetch remote branch after I cloned repo with git clone --depth 1 将远程分支与本地仓库合并 - Merging a remote branch with a local repo 将md文件从本地git仓库推送到远程github仓库 - Push md file from local git repo to remote github repo 我可以从远程仓库获取存储到本地分支吗? - Can I fetch a stash from a remote repo into a local branch? 如果在本地分支上,我该如何将该repo从已存在的本地仓库推送到远程? - If on a local branch, how should I push that repo to remote from local repo that already exists? 将远程克隆的存储库推送到我自己的github存储库,使其可更新 - push a remote cloned repo to my own github repo, keep it updatable 当在本地repo上使用filter-branch时,如何从远程仓库中提取更新? - how to pull updates from remote repo, when filter-branch is used on local repo?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM