In this guide, we will explain the method to update the Git repository. So, let’s start!
How to Update Git Repo?
To update the repository, first, we will clone the Git remote repository on Git local repository and then add an upstream remote with the given URL through the “$ git remote add upstream <remote-URL>” command. Next, fetch and download the content from Git remote repository using the “$ git pull upstream <branch>” command. It will instantly update the Git repository.
Now, let’s move ahead to understand the above-provided scenario!
Step 1: Copy Git Remote Repo URL
First, open the GitHub host service and go to the remote branch tab. Hit the “Code” button and copy its “HTTP” URL:
Step 2: Launch Git Bash
Next, open up the “Git Bash” utilizing the “Startup” menu:
Step 3: Clone Git Remote Repo
Clone the Git remote repository by specifying the copied remote repository URL in the following command:
Step 4: Add Remote Repo
Now, add the upstream remote repository with the remote URL:
Here, we have connected the upstream remote with our Git local repo:
Step 5: Update Git Repo
Next, run the “git pull” command with to update the Git repo:
The above command will fetch and download the content(remote branch) from the remote repository. In our case, our Git repo is already updated:
We have stated the procedure to update the Git repository.
Conclusion
To update the Git repository, first, execute the “$ git clone <repo-url>” to clone the Git remote repository. After that, add an upstream remote with the given URL by executing the “$ git remote add upstream <remote-URL>” command. Next, fetch and download the content from Git remote repository using the “$ git pull upstream <branch>” command, which immediately updates the Git local repo. This guide explained the method of updating the Git repository.