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


  • Cloning git repository from http URL with tortoisehg
  • can't clone git repos via http; info/refs not found
  • How do I clone a large Git repository on an unreliable connection?
  • How can I clone a git repository with a 32-bit machine?
  • Quick “git clone” from remote repository?
  • Cloning a single path of a bare git repository
  • 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?

  • How to merge commits till a certain point
  • Stop PhpStorm from automatically staging deleted files to git
  • egit and git unstaged files show different status
  • Long-term usage of branches with “git worktree”
  • Git submodule's commit matching a tag in the main repo
  • Git workflow (Dev>Staging>Live) basic technical questions
  • 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


    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.


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