Search code examples
gitgithubfetchclonepull

What is the difference between git clone, git fetch and git pull?


Could you explain the difference between git clone, git pull and git fetch? I have read some other answers but none of them state the difference between the three clearly.


Solution

  • 1 git clone

    The clone command in git is used when you want to download an existing git repository to your local computer.

    2 git pull

    When you want to take changes or updates done by other developer/team member on git repository, you have to use git pull.

    In detail git pull is the command that fetches the content from a remote repository and integrates it with the local repository/branch. It is, in actuality, a combination of git fetch and git merge called in that order.

    3 git fetch

    Git "fetch" Downloads commits, objects and refs from another repository. It fetches branches and tags from one or more repositories.

    For more details study these:

    1. https://git-scm.com/docs
    2. https://www.datacamp.com/community/tutorials/git-push-pull