gpt4 book ai didi

git - 更新 fork 的 master 并将我的分支重新定位到它上面?

转载 作者:IT王子 更新时间:2023-10-29 01:02:28 29 4
gpt4 key购买 nike

我已经 fork 了一个 github 项目,然后在本地克隆了它。

然后我在 my_github/the_project 存储库的新分支中做了一些更改。

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

所有者已收到我的请求,希望我“ rebase 到 master”以获得最新的更改。我该怎么做?

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

我想我可能需要做的是“刷新”我的 fork 以便我的 fork 的 master 是最新的,然后我可以获取那个 master 和然后 rebase 到那个主人?

如果是这种情况,我该如何刷新我的 forks master?如果不是怎么办?

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

最佳答案

是的,由于您推测的原因,它没有获取任何东西。是的,您应该在本地为上游添加一个 Remote ;它将在 master 上进行快进 merge 。

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 git@github.com: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`

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

关于git - 更新 fork 的 master 并将我的分支重新定位到它上面?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19884206/

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