DEV Community

Cover image for git pull and git fetch
Odipo Otieno (KwargDevs)
Odipo Otieno (KwargDevs)

Posted on

2

git pull and git fetch

git pull and git fetch are both commands used in Git version control system, but they perform different actions.

git fetch is used to download the latest changes from a remote repository to your local repository, but it does not automatically merge the changes with your local branch. Instead, it updates your local tracking branches such as origin/master or origin/develop to match the remote ones. This means you can review the changes that were fetched before deciding to merge them with your local branch.

git pull, on the other hand, is a combination of git fetch and git merge. When you run git pull, it downloads the latest changes from the remote repository and immediately merges them into your local branch. This means that you don't have the opportunity to review the changes before merging them with your local branch.

In summary, git fetch downloads the latest changes from a remote repository to your local repository and updates your local tracking branches, but it does not automatically merge the changes with your local branch. git pull, on the other hand, downloads the latest changes from a remote repository and immediately merges them into your local branch. The choice between using git fetch and git pull depends on your workflow and whether you want to review the changes before merging them with your local branch or not.

Top comments (0)

11 Tips That Make You a Better Typescript Programmer

typescript

1 Think in {Set}

Type is an everyday concept to programmers, but it’s surprisingly difficult to define it succinctly. I find it helpful to use Set as a conceptual model instead.

#2 Understand declared type and narrowed type

One extremely powerful typescript feature is automatic type narrowing based on control flow. This means a variable has two types associated with it at any specific point of code location: a declaration type and a narrowed type.

#3 Use discriminated union instead of optional fields

...

Read the whole post now!

πŸ‘‹ Kindness is contagious

Please leave a ❀️ or a friendly comment on this post if you found it helpful!

Okay