[英]How to fetch upstream and resolve conflicts for a forked branch locally?
I have forked a Github Repo and raised PR for some contribution.我分叉了一个 Github Repo 并提高了 PR 以做出一些贡献。 Before getting merged, some other commits were made to the parent repo.在合并之前,对父仓库进行了一些其他提交。 To fetch upstream I need to resolve conflicts with the upstream.要获取上游,我需要解决与上游的冲突。 How do I fetch upstream locally and resolve those changes?如何在本地获取上游并解决这些更改?
You can follow the GitHub docs for that, but a quick way to do it would be:您可以按照GitHub 文档进行操作,但一种快速的方法是:
Assuming you created a fork and cloned your fork only:假设您创建了一个分叉并仅克隆了您的分叉:
First thing you need to do is to add a new remote that points to the upstream project.您需要做的第一件事是添加一个指向上游项目的新远程。
In your local fork, run git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
在你的本地分支中,运行git remote add upstream https://github.com/ORIGINAL_OWNER/ORIGINAL_REPOSITORY.git
Fetch the remote: git fetch upstream
获取远程: git fetch upstream
Be sure that you are in your branch you want to merge and run git rebase upstream/<branch you want to merge to>
确保您在要合并的分支中并运行git rebase upstream/<branch you want to merge to>
This will move your branch to and will add the commits from your branch on top of that.这会将您的分支移动到并在其上添加来自您的分支的提交。
If you encounter any merge conflicts in the process, you need to:如果你在这个过程中遇到任何合并冲突,你需要:
git add
the affected file(s) git add
受影响的文件git rebase --continue
to continue with rebasing git rebase --continue
继续rebase Once you are done, use git push --force origin <your branch>
(you need to use the --force
as you changed the branch history if you previously pushed your branch)完成后,使用git push --force origin <your branch>
(如果您之前推送过分支,则需要使用--force
来更改分支历史记录)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.