| | 58 | == Branchy development: working on several tasks in parallel == |
| | 59 | |
| | 60 | You want to work on several fixes and features (tasks) and want to |
| | 61 | |
| | 62 | * keep the changes for a particular task selt-contained in a branch, |
| | 63 | * frequently update the codebase with upstream changes, |
| | 64 | * have a has-it-all branch for testing out how the different task branches interact. |
| | 65 | |
| | 66 | === Initial setup === |
| | 67 | |
| | 68 | 1. Create a fork of the automatically updated Django SVN trunk mirror on !GitHub by clicking ''fork'' at http://github.com/django/django/tree/master |
| | 69 | 1. Clone the fork to your workstation: |
| | 70 | {{{ |
| | 71 | git clone git@github.com:YOUR_NICK_HERE/django.git |
| | 72 | }}} |
| | 73 | 1. Add the upstream Django SVN mirror for tracking: |
| | 74 | {{{ |
| | 75 | cd django |
| | 76 | git remote add upstream git://github.com/django/django.git |
| | 77 | git fetch upstream |
| | 78 | }}} |
| | 79 | |
| | 80 | === Working on a task === |
| | 81 | |
| | 82 | '''Goal''': keep the changes self-contained, create and update patches suitable for attaching to [http://code.djangoproject.com/simpleticket tickets in Django trac]. |
| | 83 | |
| | 84 | 1. Create a branch from master |
| | 85 | {{{ |
| | 86 | git checkout -b ticket1234 master |
| | 87 | }}} |
| | 88 | 1. Change files, commit often |
| | 89 | {{{ |
| | 90 | git commit -am "Changed foo." |
| | 91 | }}} |
| | 92 | 1. [wiki:RunningDjangoTests Run tests] |
| | 93 | 1. Create the remote branch and push changes into it |
| | 94 | {{{ |
| | 95 | git push origin ticket1234 |
| | 96 | }}} |
| | 97 | 1. Create a patch, attach it to [http://code.djangoproject.com/simpleticket a relevant ticket in trac] |
| | 98 | {{{ |
| | 99 | git diff master > ticket1234.patch |
| | 100 | }}} |
| | 101 | |
| | 102 | Repeat for every ticket you want to work on. |
| | 103 | |
| | 104 | === After upstream has changed === |
| | 105 | |
| | 106 | '''Goal''': bring in the changes in upstream to a task. |
| | 107 | |
| | 108 | 1. When the upstream Django SVN mirror is updated, pull the updates from it (fetching and merging in one step) |
| | 109 | {{{ |
| | 110 | git pull upstream master |
| | 111 | }}} |
| | 112 | 1. Switch to the ticket branch |
| | 113 | {{{ |
| | 114 | git checkout ticket1234 |
| | 115 | }}} |
| | 116 | 1. Merge, fix any conflicts |
| | 117 | {{{ |
| | 118 | git merge master |
| | 119 | }}} |
| | 120 | 1. [wiki:RunningDjangoTests Run tests] |
| | 121 | 1. Push changes to GitHub (the remote branch was already created before) |
| | 122 | {{{ |
| | 123 | git push |
| | 124 | }}} |
| | 125 | 1. If the patch needs updating, create a new patch and attach it to the relevant ticket |
| | 126 | {{{ |
| | 127 | git diff master > ticket1234.patch |
| | 128 | }}} |
| | 129 | |
| | 130 | Repeat for every ticket you have worked on. |
| | 131 | |
| | 132 | === Testing everything in the has-it-all branch === |
| | 133 | |
| | 134 | '''Goal''': a place to try out the code from several tasks together. `master` can not be used for this as it is used for tracking upstream. This is a temporary branch that can be removed after testing is done. |
| | 135 | |
| | 136 | 1. Create the branch |
| | 137 | {{{ |
| | 138 | git checkout -b has-it-all master |
| | 139 | }}} |
| | 140 | 1. Merge in all task branches, fix any conflicts that occur in the task branches (i.e. they should merge cleanly) |
| | 141 | {{{ |
| | 142 | git merge ticket1234 |
| | 143 | git merge ticket1235 |
| | 144 | ... |
| | 145 | }}} |
| | 146 | 1. [wiki:RunningDjangoTests Run tests] |
| | 147 | 1. Delete the branch |
| | 148 | {{{ |
| | 149 | git checkout master |
| | 150 | git branch -d has-it-all |
| | 151 | }}} |
| | 152 | |