Open In App

Getting changes from a Git Repository

Git allows performing various operations on the Repositories including the local repositories and remote repositories. The user when downloads a project to work upon, a local repository is created to store a copy of the original project. This local repository stores the changes that are being made by the user. This way, the user can edit the changes before adding them to the main project. Multiple users can perform work on the same project at the same time by using local repositories.
The central repository gets updated every time a user pushes the modifications done on the local repository. These changes do not get updated on the local repository of any other developer that is working on the same project. This might create confusion because different collaborators may end up contributing the same feature in the project. To avoid this, the collaborator updates the local copy on their machine every time before starting the work on their repository. This updation of local copy is done by downloading the recent copy of the project on the central repository. This process of updating the local repository is termed as Pulling or Fetching. Git provides git pull command and git fetch command to do the cloning of the central repository into the local repository.

Pull command: Before starting the work on a project, the collaborator needs to clone his local repository with the central repository in order to get the latest copy of the project. This is done by the use of git pull command. This command updates the local repository immediately after its execution.
Syntax:



git pull <remote> <branch-name>

git pull command is a combination of two other commands which are git fetch and git merge.

Attributes of Pull Command:
Pulling changes from the central repository can be done along with the use of certain attributes that can be used to perform multiple pull operations on the repository. These attributes can be used to perform specific pulls from the repository. These are:



git pull = git fetch + git merge

Attributes of fetch command:
Fetching changes from the central repository can be done along with the use of certain attributes that can be used to perform multiple fetch operations on the repository. These attributes can be used to perform specific fetch operations from the repository. These are:

Hence, git fetch and git pull both commands can be used to update the local repository with the central repository by downloading the latest changes from the central repository.

Article Tags :
Git