What is the difference between pull and clone in git?

What is the difference between doing:

mkdir repo
cd repo
git init
git remote add origin git://github.com/cmcculloh/repo.git
git fetch --all
git pull origin master

and

  • gitolite-admin clone issue
  • Cloning a Non-Standard Svn Repository with Git-Svn
  • Clone SVN Repo to Git (with all revisions) Using Tortoise Git?
  • Git : The remote end hung up unexpectedly
  • git-update-server-info not sufficient to clone remote repo?
  • Can I link git submodules with some kind of fallback URL? If SSH clone fails, git should be able to clone using https
  • git clone git://github.com/cmcculloh/repo.git
    

    I mean, obviously one is shorter, but other than that are they basically doing the same thing?

  • Cleanup a git rebase (should have git pull'd)
  • how to pip install from github for specific date
  • 'Git Command Not found' in the custom action for SourceTree
  • Github token security using github.js
  • Converting a local svn repo dump to git
  • Git error: RPC failed; result=22, HTTP code = 404
  • 5 Solutions collect form web for “What is the difference between pull and clone in git?”

    They’re basically the same, except clone will setup additional remote tracking branches, not just master. Check out the man page:

    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.

    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).

    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.

    Hmm, what’s missing to see the remote branch “4.2” when I pull, as I do when I clone? Something’s clearly not identical.

    tmp$  mkdir some_repo
    
    tmp$  cd some_repo
    
    some_repo$  git init
    Initialized empty Git repository in /tmp/some_repo/.git/
    
    some_repo$  git pull https://github.ourplace.net/babelfish/some_repo.git
      :
    From https://github.ourplace.net/babelfish/some_repo
     * branch            HEAD       -> FETCH_HEAD
    
    some_repo$  git branch
    * master
    

    vs

    tmp$  rm -rf some_repo
    
    tmp$  git clone https://github.ourplace.net/babelfish/some_repo.git
    Cloning into 'some_repo'...
      :
    Checking connectivity... done.
    
    tmp$  cd some_repo
    
    some_repo$  git branch
    * 4.2
    

    While the git fetch command will fetch down all the changes on the server that you don’t have yet, it will not modify your working directory at all. It will simply get the data for you and let you merge it yourself. However, there is a command called git pull which is essentially a git fetch immediately followed by a git merge in most cases.

    https://git-scm.com/book/en/v2/Git-Branching-Remote-Branches#Pulling

    Git Baby is a git and github fan, let's start git clone.