开发者

What's the difference between adding and cloning a remote repository?

What's the difference between adding a remote repository and cloning a remote repository? I'm reading the pragmatic guide to git and they are talking about distributed environments and using git remote add. I'm finding the section difficult to un开发者_开发问答derstand, and why I should use it over clone.

Many thanks


Using git remote add is connecting another (remote) repository to the current repository so you can pull and push with the remote repository. For example, I do this when I push things to Github, because I already have my own "master" repository as origin.

Using git clone creates a new repository on your local system that is set up to connect to a remote repository. I would do this when getting a clone of another published project from somewhere, or making another copy of one of my own projects (perhaps on a different computer).


Git clone sets up a new repository similar to the one you are cloning ( hence the name clone!) and "adds" the remote repository from which you cloned as the remote with the name origin

Just doing the last part of setting up a remote is "adding a remote repository" and doing the whole thing and getting a new clone is cloning. Note that when you add a remote repository, you already have a repository. When you clone, you do not already have the repository.

A repository can have muliple remotes added to it via git remote add. Usually these are remote repositories of the same repo's clones on peers and servers with which you push and pull.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜