git - 更新 fork 的 master 并将我的分支重新建立到它之上?

2024-05-15

我分叉了一个 github 项目,然后将其克隆到本地。

然后我在新分支中做了一些更改my_github/the_project repo.

然后我添加并提交了更改,并推送到我的 github 存储库并提交了拉取请求。

所有者已收到我的请求,并希望我“重新定位到 master”以获取最新的更改。我该怎么做呢?

最初我以为我可以git fetch and rebase master来自我当前的分支(正如我发现的大多数帖子所建议的那样......),但是git fetch没有做任何事情。现在我意识到这可能是因为我仍在从my_ github/repo克隆(毕竟这是我在遥控器中的名字),它尚未从 github 源代码所有者那里获得 master 中的新更改。

我想我可能需要做的是“刷新”myfork 以便我的 fork 的 master 是最新的并且then我可以去叫那个主人then重新建立在那位大师的基础上?

如果是这种情况,我该如何刷新我的叉子大师?如果不是还能怎样?

我应该为原始上游存储库添加一个远程存储库并使用它来(本地)进行变基吗?这是首选方法吗?


是的,由于您猜测的原因,它没有获取任何内容。是的,您应该在本地添加一个上游上游遥控器;它将在 master 上进行快进合并。

git checkout master # Make sure you are in master
git remote add author original_repo_that_you_forked_from
    # Note: This is in the format [email protected] /cdn-cgi/l/email-protection:authors_name/repo_name.git
    #       Only needs definition once, future fetches then use it. 
git fetch author
git status # make sure you are in the master branch for the following merge
git merge author/master  # i.e. 'into' your master branch
git checkout your-branch
git rebase master        # Now get those changes into your branch.
git push origin your_branch # You can also use `-f` if necessary and `--all`

(抱歉,我的语法可能不完全正确)

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

git - 更新 fork 的 master 并将我的分支重新建立到它之上? 的相关文章

随机推荐