如何与远程Git仓库同步?

发布于 2024-10-04 23:55:16 字数 93 浏览 4 评论 0原文

我在 github 上分叉了一个项目,做了一些更改,到目前为止一切顺利。

与此同时,我派生的存储库发生了变化,我想将这些更改添加到我的存储库中。我该怎么做?

I forked a project on github, made some changes, so far so good.

In the meantime, the repository I forked from changed and I would like to get those changes into my repository. How do I do that ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

睡美人的小仙女 2024-10-11 23:55:16

一般来说 git pull 就足够了,但我不确定你选择了什么布局(或者 github 为你选择了)。

Generally git pull is enough, but I'm not sure what layout you have chosen (or has github chosen for you).

涙—继续流 2024-10-11 23:55:16

假设他们的更新位于 master 上,并且您位于要将更改合并到的分支上。

git remote add origin https://github.com/<github-username>/<repo-name>.git
git pull origin master

另请注意,您随后需要将合并推送回存储库的副本:

git push origin master

Assuming their updates are on master, and you are on the branch you want to merge the changes into.

git remote add origin https://github.com/<github-username>/<repo-name>.git
git pull origin master

Also note that you will then want to push the merge back to your copy of the repository:

git push origin master
雨后咖啡店 2024-10-11 23:55:16

您必须将原始存储库添加为上游。

这里都有很好的描述: https://help.github.com/articles/fork-一个仓库

git remote add upstream https://github.com/octocat/Spoon-Knife.git
git fetch upstream
git merge upstream/master
git push origin master

You have to add the original repo as an upstream.

It is all well described here: https://help.github.com/articles/fork-a-repo

git remote add upstream https://github.com/octocat/Spoon-Knife.git
git fetch upstream
git merge upstream/master
git push origin master
生死何惧 2024-10-11 23:55:16

您需要将原始存储库(您分叉的存储库)添加为远程存储库。

git 远程添加 github(原始存储库的克隆 url)

然后您需要将更改引入本地存储库

git 获取 github

现在您将在本地存储库中拥有原始存储库的所有分支。例如,master 分支将是 github/master。有了这些分支,你就可以做你想做的事。将它们合并到您的分支等中

You need to add the original repository (the one that you forked) as a remote.

git remote add github (clone url for the orignal repository)

Then you need to bring in the changes to your local repository

git fetch github

Now you will have all the branches of the original repository in your local one. For example, the master branch will be github/master. With these branches you can do what you will. Merge them into your branches etc

你的呼吸 2024-10-11 23:55:16

在 github UI 上,切换到要使用 fork 中的新更改进行更新的分支。
然后只需选择:

fetch upstream

On github UI, switch to the branch you want to update with new changes from fork.
Then simply select:

fetch upstream
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文