简体   繁体   中英

Does git clone copy all source code?

Does git clone create a copy of every single source file/version on your local machine, for all branches?

Or does it just copy master, and all of the branches are just references? (and when you checkout a branch it downloads commits for that branch?)

Basically I'm wondering if I have the source from 100 different branches on my machine when i really only want a small handful.

Thanks.

No it does get the full history of the remote repository.

What it doesn't get is the config and the hooks (they are not clone, pulled or pushed).

It also doesn't create a local branch for each of the remote branches cloned.
That is why if you are cloning your clone (two clones in a row), you will end up with only one branch.
As mentioned in git clone

  • Clones a repository into a newly created directory,
  • creates remote-tracking branches for each branch in the cloned repository (visible using git branch -r ), and
  • creates and checks out an initial branch that is forked from the cloned repository's currently active branch.

Short answer is that after the clone, you have all the files from the master branch, but have the full repository locally. This means you do not have to network access to checkout a different branch.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM