85 | | === Fix a bug using a bug-fix branch === |
86 | | |
87 | | Fixing a bug directly on the {{{develop}}} branch is fine, if that's the library's policy, but if the bug is messy, multiple maintainers are involved, interruptions are expected, or other complexities are present, then it is better practice to work on the bug in a separate bug-fix branch. |
88 | | |
89 | | {{{ |
90 | | git checkout -b bugfix/complex-boo-boo |
91 | | }}} |
92 | | |
93 | | This creates the branch {{{bugfix/complex-boo-boo}}}, and switches to it. Incidentally, {{{bugfix/}}} is part of the name, not a directory specifier. The new branch is based on branch {{{develop}}} because the working copy was on branch {{{develop}}} at the time of the branch. |
| 85 | There are some significant disadvantages to this simple approach: |
| 86 | * The fix is now made to {{{develop}}} but you must remember to merge it to a release branch or directly to {{{master}}}. It is very easy to forget to do that merge, particularly if this is a mature library you are not working with very often. |
| 87 | * Users who need the bug fix right away are forced to jump through hoops to retrieve the fix from {{{develop}}}. |
| 88 | |
| 89 | Putting out a point release solves both of those problems. Read on... |
| 90 | |
| 91 | === Fix a bug using a hot-fix branch === |
| 92 | |
| 93 | Fixing a bug directly on the {{{develop}}} branch is fine, if that's the library's policy, but if the bug is messy, multiple maintainers are involved, interruptions are expected, or other complexities are present, then it is better practice to work on the bug in a separate branch. And doing that on a hot-fix branch solves the problems mentioned at the end of the prior section. |
| 94 | |
| 95 | The operational distinction between a bug-fix branch and a hot-fix branch is that a bug-fix branch is branched from {{{develop}}} and then at completion merged back to {{{develop}}}, while a hot-fix branch is branched from {{{master}}} and then at completion is merged to both {{{master}}} and {{{develop}}}. With either approach, the branch is deleted after it has been merged. |
| 96 | |
| 97 | {{{ |
| 98 | git checkout master |
| 99 | git checkout -b hotfix/complex-boo-boo |
| 100 | }}} |
| 101 | |
| 102 | This creates the branch {{{hotfix/complex-boo-boo}}}, and switches to it. Incidentally, {{{hotfix/}}} is part of the name, not a directory specifier. The new branch is based on branch {{{master}}} because the working copy was on branch {{{master}}} at the time of the branch. |