Git工作叉与更新 [英] Git working fork with updates

查看:87
本文介绍了Git工作叉与更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不知道下面的场景是否可以用Git。



我把别人的仓库分开了。



我希望通过从初始存储库获取更新来处理自己的存储库副本。



偶尔,我想释放我的代码,并将请求发送到初始存储库。



我不确定这是否可能,如果是,请稍后介绍我该怎么做。

解决方案

这是可能的,但是一些最佳实践会涉及:


  • 在您自己的分支中进行修改(您可以推送到您的分支)
  • 使用 git fetch upstream (上游是引用您分叉的原始回购的远程名称)

  • 重新绑定您自己的分支更新的原始分支:

    (请参阅 git fork git clone

      git checkout myBranch 
    git rebase upstr eam / master


  • 如果你做了PR,试着让它变小一点一些提交内容),专注于一个特定的功能,而不是做一个大的提交,并提交了许多提交和许多更改。

  • b $ b

    详情请参阅夫妇关于拉请求的提示


    I wonder if the following scenario is possible with Git.

    I forked someone's repository.

    I do want to work on my own copy of the repository with getting updates from the initial repository.

    Occasionally, I do want to release my code and send pull request to initial repository.

    I am not sure if this possible, if yes please describe shortly what should I do.

    解决方案

    It is possible, but a couple of best-practices would involve:

    • doing your modification in your own branch (that you can push to your fork)
    • updating the branches common with the original repo with a git fetch upstream (upstream being the name of a remote referencing the original repo you forked)
    • rebasing your own branch on top of the updated original branch:
      (See "git fork is git clone?")

      git checkout myBranch
      git rebase upstream/master
      

    • if you do a PR, try to make it a small one (with a few commits in it), focus on a specific feature, rather than doing a large one, with many commits and many changes in it.

    See more at "couples tips on pull requests".

    这篇关于Git工作叉与更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆