8

I know the difference between git pull and git fetch .

but i want to know, Which one is Preferable?

because git pull doing merge automatically without my knowledge. thats the different i found. git fetch wont do that. is there anything else?

8
  • totally different things that are used for totally different actions on your git controlled project.... Commented Jun 23, 2017 at 9:36
  • They are completely different commands. GIt pull is actually fetch + merge(more or less). Commented Jun 23, 2017 at 9:36
  • 1
    git pull does git fetch and git merge together Commented Jun 23, 2017 at 9:37
  • Which one do you prefer? Commented Jun 23, 2017 at 9:40
  • 3
    Possible duplicate of What is the difference between 'git pull' and 'git fetch'? Commented Jun 27, 2017 at 12:04

2 Answers 2

12

Contrary to the above comments, git pull and git fetch are not completely different commands. Rather, doing a git pull on a given branch is the same as doing a git fetch followed by either merging or rebasing the current branch on its remote counterpart which was just updated.

The utility of doing a git pull is that often the reason we fetch is to update a local branch with the version on the remote. So it is a bit of a convenience. We can always do fetch followed by merge separately.

Sign up to request clarification or add additional context in comments.

Comments

8

git pull will do a git fetch and then a git merge. So it depends what do you want to do.

If you prefer to handle manually the merge you shouldn't use git pull

What is the difference between 'git pull' and 'git fetch'?

2 Comments

merge or rebase, according to your configuration.
i said i know the difference but my question is which one is preferable? pull will do merge without knowledge which is faster than fetch. but there is possibility of generating new commits. in fetch , people might forgot to merge and start to do some task . thats why

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.