gpt4 book ai didi

git - 'git remote add upstream' 帮助实现什么?

转载 作者:IT王子 更新时间:2023-10-29 00:40:45 26 4
gpt4 key购买 nike

我正在阅读: https://wiki.diasporafoundation.org/Git_workflow#Rebase_your_development_branch_on_the_latest_upstream

摘录如下:

Your Repository Up to Date

In order to get the latest updates from the development trunk do a one-time setup to establish the main GitHub repo as a remote by entering:

$ git remote add upstream git://github.com/diaspora/diaspora.git

Rebase Your Development Branch on the Latest Upstream

To keep your development branch up to date, rebase your changes on top of the current state of the upstream master. See the What’s git-rebase? section below to learn more about rebasing.

If you’ve set up an upstream branch as detailed above, and a development branch called 100-retweet-bugfix, you’d update upstream, update your local master, and rebase your branch from it like so:

$ git fetch upstream

$ git checkout master

$ git rebase upstream/master

$ git checkout 100-retweet-bugfix

[make sure all is committed as necessary in branch]

$ git rebase master

为什么在这种情况下需要添加“远程上游”?难道我刚刚做了:

$ git checkout master

$ git pull origin master

$ git checkout 100-retweet-bugfix

[确保在分支中根据需要提交所有内容]

$ git rebase master

最佳答案

Wiki 是从 fork repo 的角度来讨论的。您可以从 origin 进行 pull 和 push,这将是您对主要 diaspora 仓库的 fork 。要从此主存储库中提取更改,您可以在本地存储库中添加一个远程“上游”,指向这个原始存储库并从中提取。

所以“来源”是您的 fork 存储库的克隆,您可以从中推送和 pull 。 “上游”是主存储库的名称,您可以从中提取并更新您的分支的克隆,但您没有推送访问权限。

关于git - 'git remote add upstream' 帮助实现什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8948803/

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