0

I cloned from a certain remote github repo.

After that, I did not change anything to my local repository, but when I type git status, there shows some modified( or deleted) files.

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?

  2. If I want to clone certain branch of remote repo to my local repo, how should I do?

Thanks

invictus
  • 81
  • 5

2 Answers2

0

With Git (as with any DVCS) you have a whole standalone copy of the full repository locally. (Except if you do a shallow clone, or change the refspec so that only specific branches are cloned).

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.

If you don't want the default branch created, you can tell git clone via parameter which branch to create locally after cloning.

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. But deleted files should not be possible without you deleting the files.

Vampire
  • 35,631
  • 4
  • 76
  • 102
  • Thanks. However, some deleted files and modified files appear just right after I cloned some repo and type `git status`. I am using windows, but modified files do not seem to be related with line-ending mangling. Do you have any idea of this issue? – invictus Apr 03 '17 at 14:59
  • Not without seeing it, sorry. Sounds impossible, except maybe if there are files in the repository with filenames that are not valid or paths that are too long on windows, or files that are in the repo with the same name if case is ignored as Windows is case-insensitive. The latter case is the most probably, because about the other problems you should have gotten error messages I think. – Vampire Apr 03 '17 at 15:02
0

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.

There is some discussion of handling file mode differences here: https://stackoverflow.com/a/1580644/7275012

Community
  • 1
  • 1
Randy Leberknight
  • 1,363
  • 9
  • 17