What is the difference between pull and clone in git?

后端 未结 11 1593
太阳男子
太阳男子 2020-12-04 04:29

What is the difference between doing (after mkdir repo and cd repo):

git init
git remote add origin git://github.com/cmcculloh/repo         


        
相关标签:
11条回答
  • 2020-12-04 05:15

    Clone-: It will create exactly duplicate copy of your remote repository project in your local machine.

    Pull-: Suppose two or more than two people are sharing the same repository. (Suppose another person name is Syam) (A Repository is a place where your project exist in Github) So if Syam does some changes in the same project in his local and pushes it to the remote repository So whatever the changes Syam did those changes will not reflect in your local. So to reflect those new changes in your local you have to use git pull. Overall we use git pull to update the project.

    So basically we use git clone only once whereas we use git pull many times.

    0 讨论(0)
  • 2020-12-04 05:16

    clone: copying the remote server repository to your local machine.

    pull: get new changes other have added to your local machine.

    This is the difference.

    Clone is generally used to get remote repo copy.

    Pull is used to view other team mates added code, if you are working in teams.

    0 讨论(0)
  • 2020-12-04 05:18

    git clone is how you get a local copy of an existing repository to work on. It's usually only used once for a given repository, unless you want to have multiple working copies of it around. (Or want to get a clean copy after messing up your local one...)

    git pull (or git fetch + git merge) is how you update that local copy with new commits from the remote repository. If you are collaborating with others, it is a command that you will run frequently.

    As your first example shows, it is possible to emulate git clone with an assortment of other git commands, but it's not really the case that git pull is doing "basically the same thing" as git clone (or vice-versa).

    0 讨论(0)
  • 2020-12-04 05:18

    In laymen language we can say:

    • Clone: Get a working copy of the remote repository.
    • Pull: I am working on this, please get me the new changes that may be updated by others.
    0 讨论(0)
  • 2020-12-04 05:22

    Miss Clone: I get a fresh copy to local.

    Mr Pull: I already have it locally, I just update it.


    Miss Clone: I can do what you do! You are just my subset.

    Mr Pull: Ditto!


    Miss Clone: No, you don't create. This is what I do:

    1. Create empty bare repository
    2. Populate remote-tracking branches
    3. Run git fetch without arguments

    You only do #3, and then you merge, which I do not need to do(mine is fresh).

    Mr Pull: Smarty pants, no big deal, I will do a "git init" first! Then we are the same. Plus I have the extra 'merge' capability on existing repo! Which makes me the most used command in Git ;)


    Git creators: Hold your horses Mr Pull, if --bare or --mirror is used with clone or init, your merge won't happen. It remains read-only.

    0 讨论(0)
提交回复
热议问题