Git

Updating a Local Repository With Changes From a GitHub Repository

Git enables performing multiple operations on the Git local repositories and Git remote host repositories. When developers clone or download projects to work upon, a Git local repository is created to save a copy of the original project and the added changes by the developer.

Moreover, several team members can work on the same project using the Git local repositories. However, developers need to update the local repository with a GitHub remote repository whenever they make changes.

This study illustrated the procedure for updating a Git local repository with changes from a hosting server GitHub repository.

Updating a Local Repository With Changes From a Hosting Server GitHub Repository

For updating a local repository with changes from a GitHub repository, first, navigate to the local repository. Clone the Git local repository and execute the “$ git pull origin <branch-name>” command to update the Git local repository.

Let’s implement the above-stated step!

Step 1: Navigate to Git Local Repository

Move to the Git directory where desired remote repository exists:

$ cd "C:\Users\nazma\Git\Demo15"

Step 2: Clone Git Remote Repository
To clone the Git remote repository to the Git local repository, execute the given below command along with the remote URL:

$ git clone https://github.com/GitUser0422/demo5.git

According to the below-given output, our remote repository is cloned successfully:

Step 3: Pull Repository
Now, update the local repository with remote repository changes by executing the “git pull origin” command with the local branch name:

$ git pull origin master

As you can see, the local repository is updated with remote repository changes:

That’s it! We have offered the procedure to update the local Git repository with changes from a hosting server GitHub repository.

Conclusion

To update a local repository with changes from a hosting server GitHub repository, firstly, move to the local repository. Then, clone the Git local repository by executing the “$ git clone <remote-url>” command. Lastly, run the “$ git pull origin <branch-name>” command to update the Git local repository. This study illustrated the procedure for updating a local repository with changes from a hosting server Github repository.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.