使用git进行贡献 [英] Contributing using git

查看:145
本文介绍了使用git进行贡献的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在github上克隆了一个项目并修复了一个补丁。因为这是我第一次在git工作,我试图找出把它放在线上的最佳方式。



在github上检查我自己的(克隆的)存储库时,只有一个分支:主人。我创建了一个分支 myfix ,它现在拥有一个提交,这是该错误的修复。




  • 现在我应该将所有东西都推送到github上的克隆项目吗?我假设这会在我的github项目上创建包含该单一修订提交的分支 myfix

  • 我应该将 myfix 合并到 master 分支,移除 myfix ,然后推送所有内容?
b

在线搜索时,似乎常见的/好的做法是保持 master 不变,纯粹用于从实际/原始公共项目存储库中提取(也就是说,其他人接受了贡献和这样)。但也有人提出了其他策略:


  • 创建一个上游分支,找到它们很容易,而不是将它与其他不完整/实验性的分支混合在一起(我想知道为什么它们甚至会在线,如果它们不完整的话)。
  • 创建一个下游 em> branch, pull 其他人在此处进行离线合并更改。 目前感觉有点矫枉过正)主分支的目的是什么?



    Git可以完成上述任何组合(或全部)。这让我对如何轻松向别人展示我的作品感到困惑。是否有这种常用工作流程?或者是每个人都为自己和你>在问题跟踪器中为特定分支发布特定修订(多少次推送)以便修复bug?

    远程跟踪分支,它们可以完成您对 master 分支描述的内容。您可以列出这些远程跟踪分支:

      git分支-r 

    因为跟踪上游存储库已经完成,您通常会使用您的 master 分支对项目进行主线更改。以下是我在特定情况下应该做的事:


    • myfix 分支合并到 master 在你的克隆中。 (在主题分支中完成此操作是一种很好的做法。)

    • 将主分支分支推送到Github。 (目前还不清楚你是分叉原始仓库还是从中克隆,你需要分叉原始仓库,创建自己的副本,以便下一步工作。)

    • 发送Github 将请求发送给您分叉的存储库的所有者。


    So I have cloned a project at github and fixed a patch. Since this is the first time Im working in git Im trying to figure out the best way to put it online.

    Upon checking out my own (cloned) repository on github there was only one branch: master. I created a branch, myfix, which now holds one commit, which is the fix for the bug.

    • Should I now push everything to my cloned project on github? I assume that this would create the branch myfix on my github project containing that single fix commit.
    • Should I merge myfix into the master branch, remove myfix and then push everything?

    When searching online, it seems that the common/good practice is to leave master untouched, using that purely for pulling from the real/original public project repository (that is, others accepted contributions and such). But others suggest other strategies:

    • Create an upstream branch, put your clean and ready contributions there so others can find them easy, not mixing it up with my other incomplete/experimental branches (I wonder why these would even be online if they were so incomplete).
    • Create a downstream branch, pull others changes in here for offline merging.

    If I follow the above two (currently feels a bit overkill though) what purpose would the master branch fill?

    Git can do any combination (or all) of the above. This leaves me a bit confused as to how to easy show my work to others. Is there such a "common" workflow? Or is it every man for himself and you post a specific revision in a specific branch (thats pushed) in the issue tracker for the fixed bug?

    解决方案

    When you clone a repository, Git automatically creates remote tracking branches that do what you describe for the master branch. You can list these remote tracking branches with:

    git branch -r
    

    Because tracking the upstream repository is already done for you, you would normally use your master branch for mainline changes to the project. Here's what I would do in your particular situation:

    • Merge the myfix branch into master in your clone. (Having done this in a "topic branch" is good practice.)
    • Push the master branch to Github. (It's unclear whether you forked the original repository, or just cloned from it. You will need to fork the original repository, creating your own copy, for the next step to work.)
    • Send a Github pull request to the owner of the repository you forked.

    这篇关于使用git进行贡献的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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