Update the repository remotely by setting
In this tutorial, we will discuss how to set up the central repository as a remote for our local repository so that our branch is updated whenever the central repository changes. We should always perform this step before making edits to our local repository.
Update the repository remotely by setting
Experience:
fork
is a separate copy of the central repository that each developer adds to their GitHub account. The next step is to clone the remote repository in our account to our local machine.
We can now work on the files, commit changes and push them to our fork in our GitHub account. The last step is to complete a Pull
pull request to update the central repository with the changes in our fork.
The above is a typical workflow when working on a joint project with other developers.
All that's left is to update our local repository with the changes that other developers have pushed to the central repository. How do we do this?
Setting the upstream remote
It is important to update our local repository with the central repository before making edits to avoid merge conflicts. We need to set the central repository as the upstream remote of our local repository.
Follow these orders.
-
Go to the central repository and click on
克隆或下载
the icon to copy the repository URL. -
Go to the directory.
$ cd ~/Documents/GitHub/DelftStack-participants
-
To set the central repository as our local repository as the upstream repository, we run:
$ git remote add upstream https://github.com/Delftstack/Delftscopetech-participants.git
-
To update your local repository with the upstream, run the following command.
$ git pull upstream master
Note that we have master
designated as the receiving branch.
example:
$ git pull upstream master
remote: Counting objects: 21, done.
remote: Compressing objects: 100% (15/15), done.
remote: Total 21 (delta 14), reused 17 (delta 10), pack-reused 0
Unpacking objects: 100% (21/21), done.
From https://github.com/Delftstack/Delftscopetech-participants.git
74d9b7b..463e6f0 master -> origin/master
Auto-merging _posts/institute-materials/example.md
The above output confirms that we have synchronized our local repository with the central repository. You can run git status
the command to check the status of our local repository.
Run the git add
and git commit
commands to save the changes.
We can now start making edits to the files and committing our changes. To complete the cycle, we must push our changes to our fork in our GitHub account.
$ git push origin master
We have to use this loop when using a central remote repository.
For reprinting, please send an email to 1244347461@qq.com for approval. After obtaining the author's consent, kindly include the source as a link.
Related Articles
Rename Git repository
Publish Date:2025/04/20 Views:100 Category:OPERATING SYSTEM
-
In this article, we will discuss renaming Git repositories. We can explain this in different ways. It can rename the displayed name, the repository on GitHub, or the folder of the repository. We will discuss these and go through the steps w
Creating tags in a Git repository
Publish Date:2025/04/20 Views:117 Category:OPERATING SYSTEM
-
In this tutorial, we will discuss how to create tags in a Git repository. Creating tags in a Git repository In Git, we may want to mark certain commits or specific points in the history of the project repository. To do this, we can use the
Push Git tags to remote repositories
Publish Date:2025/04/20 Views:177 Category:OPERATING SYSTEM
-
If you create a git tag locally, your intention must be to share your changes with your team for easy tracking. Commit is one of the common operations to share changes. But another sharing and tracking idea added to it is Git Tags. This art
Fixed: Git Is Not Recognized as an Internal or External Command error
Publish Date:2025/04/20 Views:198 Category:OPERATING SYSTEM
-
This article discusses three methods we can use to fix "git" Is Not Recognized as an Internal or External Command when using Git in the Windows Command Prompt . This is a frequently reported error by users who prefer running Git commands on
Ignore untracked files in Git
Publish Date:2025/04/20 Views:162 Category:OPERATING SYSTEM
-
This article will discuss two methods that can be used to ignore untracked files in a Git repository. If there are multiple untracked files and folders in your local repository, running the git status command will output many lines. Let’s
Ignore everything except certain files in Git
Publish Date:2025/04/20 Views:151 Category:OPERATING SYSTEM
-
This article outlines the steps to make Git ignore all but a few files in a Git repository. The .gitignore file is a useful Git utility that allows us to tell Git which files to track and which files not to track. If you want your .gitignor
Get the current branch in Git
Publish Date:2025/04/20 Views:57 Category:OPERATING SYSTEM
-
This article describes how to use git branch the command and git symbolic-ref the command to get the branch you are currently working on in git. Get the current branch Use git branch the command to get a list of all branches. The branch nam
Update branches from master in Git
Publish Date:2025/04/20 Views:142 Category:OPERATING SYSTEM
-
When working in Git with many developers and analysts working on various branches simultaneously, we may encounter many problems. A common problem is when one team member makes changes in his local branch while others work on that remote br
Commit changes to a Git branch
Publish Date:2025/04/20 Views:65 Category:OPERATING SYSTEM
-
In this article, you'll learn how to save commits to a new or existing branch in Git. This article explains how to move commits to: A new branch Existing branches You’ll often find yourself committing the same staged changes to different