What is the difference between pull and clone in git?

后端 未结 11 1612
太阳男子
太阳男子 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: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.

提交回复
热议问题