Psychz - Mohsin
Votes: 0Posted On: Jun 28, 2021 13:09:59
When it comes to Git commands, Fetch and Pull requests are similar in theory, but each one is different from the other. Both are used to download from a remote repository. As a developer, maintaining your development-related data is crucial because the remote data you are looking at in your local repository is just a "snapshot." It is only updated when you download the new data from the remote location (server) using the Fetch or Pull command.
Let us take a look at how Fetch and Pull are different from each other.
Fetch Request
$ git fetch origin
The fetch command only downloads new data from a remote repository without integrating/merging any of it into your working files. Fetch never manipulates or destroys anything, and hence it can be used to get a fresh view of all the things that happened in the remote repository.
Pull Request
$ git pull origin master
Git Pull is used to download and update new data into your current Head branch issuing all the latest changes from the remote server. Since it directly integrates into your recent working files, which leads to some complications. It would be best if you carefully understood the implications of it. Following are some consequences
Since "git pull" tries to merge remote changes with your local ones, a so-called "merge conflict" can occur. When you combine branches with competing commits and git is confused about which changes to go ahead with.
To know more on how to deal with this issue, please visit git's documentation https://docs.github.com/en/github/collaborating-with-pull-requests/addressing-merge-conflicts/about-merge-conflicts
The second issue you can face with Pull requests is that you need to ensure that you perform this on a clean working copy of the code. That means you should not have any uncommitted local changes before you Pull.
Hope you find the above information helpful and useful. Please vote us if you like the response.