我在一个开源项目中工作,并已经 fork 了它。有人也 fork 了它并正在使用一些有趣的想法,但不会很快推送到原始库。我想帮助他,因此我将他的 fork 克隆到了我的计算机上。然而,我不能直接将我的工作推送到他的 fork 上。我也不能再 fork 一次,因为我已经从原始库进行了 fork。我该怎么办?谢谢。
我在一个开源项目中工作,并已经 fork 了它。有人也 fork 了它并正在使用一些有趣的想法,但不会很快推送到原始库。我想帮助他,因此我将他的 fork 克隆到了我的计算机上。然而,我不能直接将我的工作推送到他的 fork 上。我也不能再 fork 一次,因为我已经从原始库进行了 fork。我该怎么办?谢谢。
#Add the forked repo as another remote to your local repository
git remote add someone https://fork.url #create remote called "someone"
#fetch the changes from that remote
git fetch someone
#rebase the work you want to send onto the fork's work
git branch for-someone my-branch #create branch "for-someone" at "my-branch"
git rebase master for-someone --onto someone/master #take commits from the "for-someone" branch down to your "master" branch and rebase it onto someone's "master" branch
#then push your changes to the other remote
git push someone for-someone #push branch "for-someone" to the "someone" remote
请更改远程和分支名称为更合适的名称。
git remote add
步骤,直接使用fork的URL(在这个例子中为https://fork.url
)作为origin。也就是说,只需要执行:git push https://fork.url for-someone
即可。这种方法在最近的git版本中也适用。 - rugk你可以像@jeff-mercado提到的那样做两件事情。这将是一个复杂的任务,我建议你使用基于GUI的git客户端来完成。我曾经遇到过与你相同的问题,并发现Sublime Merge非常有用。
我建议你要求他向你发送PR。 然后你就能够将他的更改合并到你的存储库中 最后,你可以将合并后的存储库推送到你的github上,并要求他克隆并推送。 (这是假设另一个人不会做合并你的PR的工作,这对你来说会更容易。)