What is difference between "git pull" and "git fetch" in Git?

Dung Do Tien Nov 13 2021 93

Hello, I just switch from SVN to Git. I only know a little about Git with git clone, git push,  git pull. And today I know more about git fetch

I research on the internet I feel it same with git pull. So what is the difference between git pull and git fetch?

I only know git pull helps me get all new code from the current branch I'm working for.  

Now I really don't know when I should use git pull or git fetch.

Thank you many for any clear explanation!!!

Have 2 answer(s) found.
  • P

    PTJ312 Nov 13 2021

    git fetch is the command that tells your local git to retrieve the latest data info from the original branch, ONLY see have any new commit from original not update that to local git.

    git pull on the other hand does that AND brings (copy) those changes from the remote repository and APPLY all that new change to local git.

  • א

    אופק סדלובסקי Nov 13 2021

    git pull command is used to fetch and download content from a remote repository and immediately update the local repository to match that content.

    git fetch command will downloads commits, files, and refs from a remote repository into your local repo but not update immediately.

Leave An Answer
* NOTE: You need Login before leave an answer

* Type maximum 2000 characters.

* All comments have to wait approved before display.

* Please polite comment and respect questions and answers of others.

Popular Tips

X Close