What's the difference between the git fetch and git pull commands?
I have seen some users use
git fetch, and some use
git pull. But I did not understand the difference between both. Please explain when to use
git fetch and
In the simplest terms,
git pull = git fetch && git merge FETCH_HEAD
You can use
git fetch at any time to update your remote-tracking branches under
refs/remotes/<remote>/. This command never changes any of your local branches under
refs/heads, and is safe to do without changing your working copy.
git pull is used to bring a local branch fully up-to-date with its remote version, while additionally updating your other remote-tracking branches.
git fetch only downloads new data from a remote repository - yet it doesn't integrate any of this new data into your working files. Fetch is incredible for getting a fresh view of all the things that occurred in a remote repository.
git pull is used to update your current HEAD branch with the most recent changes from the remote server. This implies that pull not just downloads new data; it likewise directly integrates it into your present working copy files.
Please login or create new account to participate in this conversation.