PASSWORD RESET

Your destination for complete Tech news

Git

What is the difference between ‘git pull’ and ‘git fetch’?

257 0
< 1 min read

git pull and git fetch are both commands that are used to download new commits and data from a remote repository. However, they differ in how they integrate the new data into the local repository.

git pull is a combination of git fetch and git merge. It downloads new commits and data from the remote repository, and then merges the changes into the current branch in the local repository. git pull updates the local branches with the upstream changes and is useful when you want to keep your local repository up to date with the remote repository.

git pull

git fetch, on the other hand, only downloads new commits and data from the remote repository and stores them in the local repository. It does not integrate the new data into the local branches, but stores it in a separate branch called origin/branch-name. You can then use the git merge command to merge the changes from the origin/branch-name branch into the local branch.

git fetch
git merge origin/branch-name

git fetch is useful when you want to review the changes that have been made in the remote repository before integrating them into your local repository. It allows you to see what has changed and decide whether you want to merge the changes into your local repository or not.

In summary, git pull combines git fetch and git merge and is useful when you want to keep your local repository up to date with the remote repository. git fetch only downloads new commits and data from the remote repository and is useful when you want to review the changes before integrating them into your local repository.

Leave A Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.