What do you do when you find a bug in other function when develop a function?

For example, there are several big functions: User [need to develop UserControl, UserModel, UserService], and Admin , Post , Comment .

Now you are in features/post branch, developing post related functions. But you come across some bugs in User related functions.

So in terms of gitflow, what is the suggested way to do?

  • add TODO or Fix me to User related functions, and fix the bug after finish the development of post and merged the code to master?

  • stash the unfinished post related code, create a fix branch, fix the bug, merge to features/post , stash pop the unfinished post related code, then go on?


  • You can freely fix whatever you like, whether or not it is related to the "topic" that you are working on.

    Then use git commit --patch to only add commit those changes which adhere to the topic. (It is well worth learning all the details of this workflow, including how to split hunks into smaller changes, and how to edit hunks that cannot be split, yet contain a mixture of wanted and unwanted changes).

    When the topic commits are all made using one or more git commit --patch operations, then all that remains in the working copy are the off-topic changes. At that point you can git checkout to a different branch to commit those, if appropriate, using git stash save and git stash pop to work around any complaints that you have unstaged changes.

    If everything is in the same branch, then perhaps order doesn't matter. You can just git commit --patch the bugfix you discovered, then continue with the topic. If the fix lands in the middle of ongoing topic fixes, you can always git rebase -i : interactively rebase it so that the topic commits are together, and the incidental bugfix is before or after.

    In my software organization, I'd have to create a ticket and obtain a bug number for this incidental bugfix, and submit it into Gerrit for review. If it's something obvious that looks like would get approved quickly and easily, I'd do that first, ahead of the "weighty" changes I'm working on.


    I didn't find GitFlow defines that.

    For me, basing on the critical of BUG, I will decide to fix it immediately or add TODO to fix it later.

    I do not fix it in the same branch with current developing feature, because it will make my teammates confused when they review my source code.


    I don't follow git-flow specifically, but here's what I try to do:

  • Stash, or use git-worktree .
  • Fix the bug in the relevant upstream branch.
  • Merge the fix into the working branch (usually I rebase this later).

  • Alternatively, you could initially fix it in the current branch as a discrete commit, then git cherry-pick it into the upstream branch and git rebase to drop it from the current branch.

    链接地址: http://www.djcxy.com/p/92466.html

    上一篇: Android:透明状态栏,带有动态的动作条颜色和DrawerLayout

    下一篇: 开发函数时,如果在其他函数中发现错误,您会做什么?