gpt4 book ai didi

git - 如何更新 fork 的 git 仓库?

转载 作者:太空狗 更新时间:2023-10-29 12:44:55 27 4
gpt4 key购买 nike

我已经 fork 了一个 git 仓库。如果源有更新, fork 的 repo 是否会自动更新?或者我应该在 cmd 中执行一些命令来更新这个 fork 的 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. To keep track of the original repo, you need to add another remote named 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

关于git - 如何更新 fork 的 git 仓库?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11875723/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com