如何在不创建新提交的情况下同步分叉的存储库 [英] How to sync forked repository without creating a new commit
问题描述
我为 PR github.com/checkstyle/checkstyle/issues/4365rel =nofollow noreferrer>这个问题,过了一段时间后,主存储库更新了新的可接受的PR,而我的fork位于主存储库后面。
因此,现在我尝试同步我的Forked Repositoy,但这不是问题的终结,我必须同步我的提交或登录主存储库。
如何将我的分叉存储库时间线/日志与主存储库同步。
问题在于更新的提交,它们被粘贴到单个提交中,作为一个单独的提交(组合10个或更多的提交)在fork日志中
这是预期的,因为你已经拉(取+ > merge )
我建议你在本地删除合并提交,并在<$ c $之上重新绑定(即重放提交) c>上游/主账户(使用上游
作为原始仓库的远程名称)
<另外,我会在一个专门的分支中隔离这些更改,但是由于您已经从
master
开始了PR,所以让我们继续讨论 master code>。
请确保您没有进行任何本地工作。
cd / path / to / local / repo
git remote add upstream< Repository URL>
检查 git remote -v
:您应该看到上游
和原点
,原点引用您的分支。
git log#确保master HEAD在正确的地方提交
git fetch upstream
git rebase upstream / master
#test if if everything仍在工作
git push --force
I created a PR for this issue, after a while the main repository is updated with new accepted PRs and my fork is behind the main repository.
So now I tried to synchronize my Forked Repositoy, but that's not the end of the problem I have to sync my commits or log with the main repository.
How do I synchronize my forked repository time-line/logs with the main repository.
解决方案
The problem is with the updated commits, they are glued into a single commit, which appears as a single commit(combo of 10 or more commits) in fork log
That is expected, since you have pulled (fetch+merge)
I would advise you to locally remove to remove that merge commit, and rebase (ie replay your commits) on top of upstream/master
(with upstream
being the remote name for the original repo)
Plus, I would have isolated those changes in a dedicated branch, but since you have started the PR from master
, let's stay on master
.
Make sure you don't have any local work in progress.
cd /path/to/local/repo
git remote add upstream <Repository URL>
Check the output of git remote -v
: you should see upstream
and origin
, with origin referencing your fork.
git log # make sure master HEAD is at the right commit
git fetch upstream
git rebase upstream/master
# test if everything is still working
git push --force
这篇关于如何在不创建新提交的情况下同步分叉的存储库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!