简体   繁体   English

单个开发人员的Github工作流程

[英]Github workflow for single developer

I would like some feedback on my git workflow because this is my first use of it and despite reading various articles and Stack Overflow questions, I'm not sure that my process is correct. 我想对我的git工作流程提供一些反馈,因为这是我第一次使用它,尽管阅读了各种文章和Stack Overflow问题,但我不确定我的流程是否正确。 This is my current workflow (note that I am using the Github for Windows application for all of my git interactions): 这是我当前的工作流程(请注意,我正在使用Github for Windows应用程序进行所有git交互):

  1. Decide what the next feature is that I'm going to implement. 确定我将要实现的下一个功能。
  2. Create a branch with a suitably descriptive name for the feature. 创建一个具有适当描述性名称的分支。 I do this by clicking on the branch button in Github for Windows and typing a new name. 我通过单击Github for Windows中的分支按钮并键入新名称来完成此操作。
  3. Write some code. 写一些代码。
  4. Commit those changes to my new branch. 将这些更改提交给我的新分支。
  5. Write some more code. 写一些代码。
  6. Commit those changes to my new branch. 将这些更改提交给我的新分支。
  7. I've finished implementing the feature so I want to merge my changes back to the master branch. 我已经完成了该功能的实现,因此我想将我的更改合并回主分支。 So I click on the 'manage' button underneath the branch heading. 所以我点击分支标题下面的“管理”按钮。
  8. Merge the new branch into the master branch. 将新分支合并到主分支中。
  9. Delete the new branch. 删除新分支。

I am quite happy with the process up until step 7 at which point I am a little confused. 我对这个过程非常满意,直到第7步,我有点困惑。 I think my confusion lies in the fact that I'm trying to use the Github for Windows application rather than using the command line. 我认为我的困惑在于我正在尝试使用Github for Windows应用程序而不是使用命令行。 The application does seem to make things easier but there is a bit of a disconnect in my understanding between some of the commands/instructions I see mentioned and the actions you would take in the application. 该应用程序确实使事情变得更容易,但我对我提到的一些命令/指令与您在应用程序中将采取的操作之间的理解存在一些脱节。

Let me ask some specific questions: 让我问一些具体问题:

  1. Is my workflow actually correct? 我的工作流程是否正确? If not, what is wrong with it and how can I improve it? 如果没有,它有什么问题,我该如何改进呢?
  2. Should I be "publishing" my changes to the new branch? 我应该将我的更改“发布”到新分支吗? My understanding is that this is the equivalent of doing git push at the command line. 我的理解是,这相当于在命令行执行git push Is that true? 真的吗? If so I think I would only want to do that when I am either finished implementing the feature or it is in a decent state? 如果是这样的话,我想我只想在完成功能实现或处于体面状态时才这样做?
  3. Should I be deleting the branch when I have merged it into the master branch or should it be left around forever? 我是否应该在将其合并到主分支中时删除分支,还是应该永久保留?
  4. Do I need to publish the master branch when I have completed the merge or is this implicit? 完成合并后是否需要发布主分支?这是隐含的吗?
  5. I am sometimes unable to perform the merge and get this error message: 我有时无法执行合并并收到此错误消息:

    Unable to merge 无法合并

    Failed to merge 'test' into 'master'. 无法将'test'合并到'master'中。 You might need to open a shell and debug the state of this repo. 您可能需要打开shell并调试此repo的状态。

When this occurred before, I was able to change to the master branch and merge the new branch into the master branch however that no longer works. 当之前发生这种情况时,我能够更改为主分支并将新分支合并到主分支中,但不再有效。 No matter which branch I am in, I cannot merge the two branches. 无论我在哪个分支,我都无法合并这两个分支。 Both are in sync and I've published all the changes from my test branch. 两者都是同步的,我已经发布了测试分支的所有更改。 What should I be typing in the shell to find out why I can't merge the branches? 我应该在shell中输入什么来找出为什么我不能合并分支?

For reference, these are the main links that have prompted my process: 作为参考,这些是促使我的过程的主要链接:

  1. Scott Chacon on the workflow at Gitub Scott Chacon关于Gitub的工作流程
  2. Git workflow for a single developer on a local repository Git本地存储库上的单个开发人员的工作流程
  3. Git workflow for a single user 单个用户的Git工作流程

What you are describing sounds like a common branching workflow that works very well even for multiple developers on the same code base. 您所描述的内容听起来像是一个常见的分支工作流程,即使对于同一代码库上的多个开发人员也能很好地工作。 It's pretty much completely covered by git flow which is a extension of git command line to automate certain steps. 它完全由git flow覆盖,它是git命令行的扩展,用于自动执行某些步骤。 It's worth checking out. 值得一试。

I'm not a big fan of UI tools for git. 我不是git UI工具的忠实粉丝。 I'm using the command line most of the time. 我大部分时间都在使用命令行。 So I'm not experienced with GitHub for Windows. 所以我对GitHub for Windows没有经验。 But I bet your problems occur because of your merges are no fast-forwards anymore. 但我打赌你的问题会因为你的合并而不再是快进而发生。 This would require a manual merge step that is (afaik) not covered by the tool. 这将需要手动合并步骤(afaik)未被工具覆盖。

There is no strong reason to keep branches around after merging them into your upstream. 在将它们合并到您的上游后,没有充分的理由保持分支。 But one is to track what commits went into a certain feature. 但一个是跟踪提交进入某个功能的内容。 I would suggest to publish the branches if you decide to keep them. 如果您决定保留它们,我建议发布分支机构。 You are not dependent on the code lying around on you local machine. 您不依赖于本地计算机上的代码。 To keep the branches doesn't make your repository much bigger by the way but pollutes the sight. 保持分支不会使你的存储库变得更大,但会污染视线。 Most of the time the commits are present anyway in your upstream branch. 大多数情况下,提交在您的上游分支中都存在。

You will have to publish (push) your master branch after merging in. 合并后,您必须发布(推送)主分支。

To get familiar with the git command line tool I suggest starting with the Introduction to Git and GitHub from the GitHub guys and follow their link references for more details. 为了熟悉git命令行工具,我建议从GitHub的Git和GitHub简介开始,并按照他们的链接参考了解更多细节。

Hope that helps 希望有所帮助

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM