简体   繁体   English

如何更新分叉的 git repo?

[英]How to update a forked git repo?

I have forked a git repo.我已经分叉了一个 git repo。 Is the forked repo automatically updated if the origin has updates?如果源有更新,分叉的 repo 会自动更新吗? Or should I perform some commands in cmd to make this forked repo updated?或者我应该在 cmd 中执行一些命令来更新这个分叉的回购吗? What are this commands?这是什么命令?

They have very specific help on this topic on the github docs: https://help.github.com/articles/fork-a-repo他们在 github 文档中对这个主题有非常具体的帮助: https : //help.github.com/articles/fork-a-repo

Configure remotes配置遥控器

When a repo is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repo it was forked from.当一个 repo 被克隆时,它有一个名为 origin 的默认远程指向你在 GitHub 上的分叉,而不是它被分叉的原始 repo。 To keep track of the original repo, you need to add another remote named upstream:要跟踪原始存储库,您需要添加另一个名为 upstream 的远程:

git remote add upstream https://github.com/octocat/Spoon-Knife.git
# Assigns the original repo to a remote called "upstream"

git fetch upstream
# Pulls in changes not present in your local repository, 
# without modifying your files

Pull in upstream changes引入上游变化

If the original repo you forked your project from gets updated, you can add those updates to your fork by running the following code:如果您分叉项目的原始存储库得到更新,您可以通过运行以下代码将这些更新添加到您的分叉中:

git fetch upstream
# Fetches any new changes from the original repo

git merge upstream/master
# Merges any changes fetched into your working files

When a repo is cloned, it has a default remote called origin that points to your fork on GitHub, not the original repo it was forked from.当一个 repo 被克隆时,它有一个名为 origin 的默认远程指向你在 GitHub 上的分叉,而不是它被分叉的原始 repo。 To keep track of the original repo, you need to add another remote named upstream:要跟踪原始存储库,您需要添加另一个名为 upstream 的远程:

As they say in this Blog Post .正如他们在这篇博客文章中所说。

Recently, I updated my forked repo following this URL .最近,我按照这个URL更新了我的分叉仓库。 This URL explains updating the forked repo using web UI as well as terminal.此 URL 解释了如何使用 Web UI 和终端更新分叉存储库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM