|
| 1 | +.. _development-workflow: |
| 2 | + |
| 3 | +==================== |
| 4 | +Development workflow |
| 5 | +==================== |
| 6 | + |
| 7 | +You already have your own forked copy of the matplotlib_ repository, by |
| 8 | +following :ref:`forking`, :ref:`set-up-fork`, and you have configured |
| 9 | +git_ by following :ref:`configure-git`. |
| 10 | + |
| 11 | +Workflow summary |
| 12 | +================ |
| 13 | + |
| 14 | +* Keep your ``master`` branch clean of edits that have not been merged |
| 15 | + to the main matplotlib_ development repo. Your ``master`` then will follow |
| 16 | + the main matplotlib_ repository. |
| 17 | +* Start a new *feature branch* for each set of edits that you do. |
| 18 | +* If you can avoid it, try not to merge other branches into your feature |
| 19 | + branch while you are working. |
| 20 | +* Ask for review! |
| 21 | + |
| 22 | +This way of working really helps to keep work well organized, and in |
| 23 | +keeping history as clear as possible. |
| 24 | + |
| 25 | +See |emdash| for example |emdash| `linux git workflow`_. |
| 26 | + |
| 27 | +Making a new feature branch |
| 28 | +=========================== |
| 29 | + |
| 30 | +:: |
| 31 | + |
| 32 | + git branch my-new-feature |
| 33 | + git checkout my-new-feature |
| 34 | + |
| 35 | +Generally, you will want to keep this also on your public github_ fork |
| 36 | +of matplotlib_. To do this, you `git push`_ this new branch up to your github_ |
| 37 | +repo. Generally (if you followed the instructions in these pages, and |
| 38 | +by default), git will have a link to your github_ repo, called |
| 39 | +``origin``. You push up to your own repo on github_ with:: |
| 40 | + |
| 41 | + git push origin my-new-feature |
| 42 | + |
| 43 | +In git >1.7 you can ensure that the link is correctly set by using the |
| 44 | +``--set-upstream`` option:: |
| 45 | + |
| 46 | + git push --set-upstream origin my-new-feature |
| 47 | + |
| 48 | +From now on git_ will know that ``my-new-feature`` is related to the |
| 49 | +``my-new-feature`` branch in the github_ repo. |
| 50 | + |
| 51 | +The editing workflow |
| 52 | +==================== |
| 53 | + |
| 54 | +Overview |
| 55 | +-------- |
| 56 | + |
| 57 | +:: |
| 58 | + |
| 59 | + # hack hack |
| 60 | + git add my_new_file |
| 61 | + git commit -am 'NF - some message' |
| 62 | + git push |
| 63 | + |
| 64 | +In more detail |
| 65 | +-------------- |
| 66 | + |
| 67 | +#. Make some changes |
| 68 | +#. See which files have changed with ``git status`` (see `git status`_). |
| 69 | + You'll see a listing like this one:: |
| 70 | + |
| 71 | + # On branch ny-new-feature |
| 72 | + # Changed but not updated: |
| 73 | + # (use "git add <file>..." to update what will be committed) |
| 74 | + # (use "git checkout -- <file>..." to discard changes in working directory) |
| 75 | + # |
| 76 | + # modified: README |
| 77 | + # |
| 78 | + # Untracked files: |
| 79 | + # (use "git add <file>..." to include in what will be committed) |
| 80 | + # |
| 81 | + # INSTALL |
| 82 | + no changes added to commit (use "git add" and/or "git commit -a") |
| 83 | + |
| 84 | +#. Check what the actual changes are with ``git diff`` (`git diff`_). |
| 85 | +#. Add any new files to version control ``git add new_file_name`` (see |
| 86 | + `git add`_). |
| 87 | +#. To commit all modified files into the local copy of your repo,, do |
| 88 | + ``git commit -am 'A commit message'``. Note the ``-am`` options to |
| 89 | + ``commit``. The ``m`` flag just signals that you're going to type a |
| 90 | + message on the command line. The ``a`` flag |emdash| you can just take on |
| 91 | + faith |emdash| or see `why the -a flag?`_ |emdash| and the helpful use-case |
| 92 | + description in the `tangled working copy problem`_. The `git commit`_ manual |
| 93 | + page might also be useful. |
| 94 | +#. To push the changes up to your forked repo on github_, do a ``git |
| 95 | + push`` (see `git push`). |
| 96 | + |
| 97 | +Asking for code review |
| 98 | +====================== |
| 99 | + |
| 100 | +#. Go to your repo URL |emdash| e.g. ``http://github.com/your-user-name/matplotlib``. |
| 101 | +#. Click on the *Branch list* button: |
| 102 | + |
| 103 | + .. image:: branch_list.png |
| 104 | + |
| 105 | +#. Click on the *Compare* button for your feature branch |emdash| here ``my-new-feature``: |
| 106 | + |
| 107 | + .. image:: branch_list_compare.png |
| 108 | + |
| 109 | +#. If asked, select the *base* and *comparison* branch names you want to |
| 110 | + compare. Usually these will be ``master`` and ``my-new-feature`` |
| 111 | + (where that is your feature branch name). |
| 112 | +#. At this point you should get a nice summary of the changes. Copy the |
| 113 | + URL for this, and post it to the `matplotlib mailing list`_, asking for |
| 114 | + review. The URL will look something like: |
| 115 | + ``http://github.com/your-user-name/matplotlib/compare/master...my-new-feature``. |
| 116 | + There's an example at |
| 117 | + http://github.com/matthew-brett/nipy/compare/master...find-install-data |
| 118 | + See: http://github.com/blog/612-introducing-github-compare-view for |
| 119 | + more detail. |
| 120 | + |
| 121 | +The generated comparison, is between your feature branch |
| 122 | +``my-new-feature``, and the place in ``master`` from which you branched |
| 123 | +``my-new-feature``. In other words, you can keep updating ``master`` |
| 124 | +without interfering with the output from the comparison. More detail? |
| 125 | +Note the three dots in the URL above (``master...my-new-feature``) and |
| 126 | +see :ref:`dot2-dot3`. |
| 127 | + |
| 128 | +Asking for your changes to be merged with the main repo |
| 129 | +======================================================= |
| 130 | + |
| 131 | +When you are ready to ask for the merge of your code: |
| 132 | + |
| 133 | +#. Go to the URL of your forked repo, say |
| 134 | + ``http://github.com/your-user-name/matplotlib.git``. |
| 135 | +#. Click on the 'Pull request' button: |
| 136 | + |
| 137 | + .. image:: pull_button.png |
| 138 | + |
| 139 | + Enter a message; we suggest you select only ``matplotlib`` as the |
| 140 | + recipient. The message will go to the `matplotlib mailing list`_. Please |
| 141 | + feel free to add others from the list as you like. |
| 142 | + |
| 143 | +Merging from trunk |
| 144 | +================== |
| 145 | + |
| 146 | +This updates your code from the upstream `matplotlib github`_ repo. |
| 147 | + |
| 148 | +Overview |
| 149 | +-------- |
| 150 | + |
| 151 | +:: |
| 152 | + |
| 153 | + # go to your master branch |
| 154 | + git checkout master |
| 155 | + # pull changes from github |
| 156 | + git fetch upstream |
| 157 | + # merge from upstream |
| 158 | + git merge upstream/master |
| 159 | + |
| 160 | +In detail |
| 161 | +--------- |
| 162 | + |
| 163 | +We suggest that you do this only for your ``master`` branch, and leave |
| 164 | +your 'feature' branches unmerged, to keep their history as clean as |
| 165 | +possible. This makes code review easier:: |
| 166 | + |
| 167 | + git checkout master |
| 168 | + |
| 169 | +Make sure you have done :ref:`linking-to-upstream`. |
| 170 | + |
| 171 | +Merge the upstream code into your current development by first pulling |
| 172 | +the upstream repo to a copy on your local machine:: |
| 173 | + |
| 174 | + git fetch upstream |
| 175 | + |
| 176 | +then merging into your current branch:: |
| 177 | + |
| 178 | + git merge upstream/master |
| 179 | + |
| 180 | +Deleting a branch on github_ |
| 181 | +============================ |
| 182 | + |
| 183 | +:: |
| 184 | + |
| 185 | + git checkout master |
| 186 | + # delete branch locally |
| 187 | + git branch -D my-unwanted-branch |
| 188 | + # delete branch on github |
| 189 | + git push origin :my-unwanted-branch |
| 190 | + |
| 191 | +(Note the colon ``:`` before ``test-branch``. See also: |
| 192 | +http://github.com/guides/remove-a-remote-branch |
| 193 | + |
| 194 | +Several people sharing a single repository |
| 195 | +========================================== |
| 196 | + |
| 197 | +If you want to work on some stuff with other people, where you are all |
| 198 | +committing into the same repository, or even the same branch, then just |
| 199 | +share it via github_. |
| 200 | + |
| 201 | +First fork matplotlib into your account, as from :ref:`forking`. |
| 202 | + |
| 203 | +Then, go to your forked repository github page, say |
| 204 | +``http://github.com/your-user-name/matplotlib`` |
| 205 | + |
| 206 | +Click on the 'Admin' button, and add anyone else to the repo as a |
| 207 | +collaborator: |
| 208 | + |
| 209 | + .. image:: pull_button.png |
| 210 | + |
| 211 | +Now all those people can do:: |
| 212 | + |
| 213 | + git clone git@githhub.com:your-user-name/matplotlib.git |
| 214 | + |
| 215 | +Remember that links starting with ``git@`` use the ssh protocol and are |
| 216 | +read-write; links starting with ``git://`` are read-only. |
| 217 | + |
| 218 | +Your collaborators can then commit directly into that repo with the |
| 219 | +usual:: |
| 220 | + |
| 221 | + git commit -am 'ENH - much better code' |
| 222 | + git push origin master # pushes directly into your repo |
| 223 | + |
| 224 | +Exploring your repository |
| 225 | +========================= |
| 226 | + |
| 227 | +To see a graphical representation of the repository branches and |
| 228 | +commits:: |
| 229 | + |
| 230 | + gitk --all |
| 231 | + |
| 232 | +To see a linear list of commits for this branch:: |
| 233 | + |
| 234 | + git log |
| 235 | + |
| 236 | +You can also look at the `network graph visualizer`_ for your github_ |
| 237 | +repo. |
| 238 | + |
| 239 | +.. include:: links.inc |
0 commit comments