如何保持你的分支仓库处于最新状态

2025-05-26

如何保持你的分支仓库处于最新状态

你是开源新手吗?如果是,希望你已经利用 Hacktoberfest 初次涉足开源领域。将你的第一个拉取请求合并到一个大型项目中,感觉非常激动人心,但接下来会发生什么呢?如果你想继续在这个项目上工作,你需要保持你的分支处于最新状态。

以下是有关如何从头到尾执行此操作的一些快速说明。

感谢GitHub提供了非常清晰的说明。所有步骤都集中在这里。

# If you haven't already added an upstream source, set your upstream
# to the fork's original source
git remote add upstream <url_to_original>

# Verify upstream is correct, you should see the URL for the upstream fetch and push
git remote -v

# Get all recent branches and commits from the upstream
git fetch upstream

# Check out your current master branch
git checkout master

# Merge the branches and commits from the upstream
git merge upstream/master

# Push the updated master to your forked remote repository
git push origin master

就这样。你应该已经了解了最新情况,可以准备进行下一个 PR 了。

封面图片由Salvatore G2 在 Flickr 上提供

文章来源:https://dev.to/ranewallin/how-to-keep-your-forked-repository-current-38mn
PREV
2022 年 45 个最佳 Figma 登陆页面模板(免费)
NEXT
useActionState — React 中的新 Hook 🎉