@@ -163,141 +163,6 @@ C/C++ extensions
163163 docstrings, and the Numpydoc format is well understood in the
164164 scientific Python community.
165165
166- Rebasing a Pull Request (PR)
167- ----------------------------
168-
169- When working on a PR, changes may occur in the parent branch (usually master).
170- This can lead to conflict with changes in your branch. The conflicts can be
171- trivial: for example both the parent branch and your branch add an entry to
172- the top of `CHANGELOG `. Git can not unambiguously tell what to with both
173- changes (should one go above the other? if so, which order? should it try to
174- merge them?) so it declares the branches can not be merged
175- cleanly. Github can only automatically merge PR without conflicts, so you will
176- need to manually 'rebase'. This is the process of updating your branch with
177- upstream changes, and resolving conflicts.
178-
179- In git, rebasing is a mild form of re-writing history: it effectively forwards
180- all your commits to the updated upstream commit. For a much more detailed
181- explanation (with pictures!) see `this nice write up
182- <http://git-scm.com/book/en/Git-Branching-Rebasing> `. The numpy team has also
183- `documented how to do this
184- <http://docs.scipy.org/doc/numpy/dev/gitwash/development_workflow.html#rebasing-on-master> `
185- In general, re-writing history, particularly published history, is considered
186- bad practice, but in this case it is very useful.
187-
188- The following example assumes that the remote of _your_ github
189- repository is called `github ` and the remote of the official
190- repository is called `matplotlib `.
191-
192- The first step is to make sure that your local copy of the upstream repository is
193- up-to-date::
194-
195- $ git fetch matplotlib
196-
197- This updates your local copy of the repository, but does not change any files
198- in your working copy. Next, switch to the branch that you want to update::
199-
200- $ git checkout backend_plt_refactor
201-
202- You are now ready to start the rebase of your branch onto the target
203- parent branch, in this case `matplotlib/master ` ::
204-
205- $ git rebase matplotlib/master
206-
207- and git will then give a bunch of feed back::
208-
209- First, rewinding head to replay your work on top of it...
210- Applying: first steps to extract FigureManager* and friends from pyplot
211- Applying: split backend_qt4 into two parts, with and without Gcf
212- ...
213- Applying: pep8 clean up on backend_gtk3.py
214- Using index info to reconstruct a base tree...
215- M lib/matplotlib/backends/backend_gtk3.py
216- Falling back to patching base and 3-way merge...
217- Auto-merging lib/matplotlib/backends/backend_gtk3.py
218- CONFLICT (content): Merge conflict in lib/matplotlib/backends/backend_gtk3.py
219- Failed to merge in the changes.
220- Patch failed at 0013 pep8 clean up on backend_gtk3.py
221- The copy of the patch that failed is found in:
222- /home/tcaswell/other_source/matplotlib/.git/rebase-apply/patch
223-
224- When you have resolved this problem, run "git rebase --continue".
225- If you prefer to skip this patch, run "git rebase --skip" instead.
226- To check out the original branch and stop rebasing, run "git rebase --abort".
227-
228- A number of commits could be cleanly applied to
229- the tip of `matplotlib/master `, however, git eventually hits a commit
230- that had conflicts. In this case in the file
231- `lib/matplotlib/backends/backend_gtk3.py `. For more verbose information run ::
232-
233- $ git status
234-
235- You are currently rebasing branch 'backend_plt_refactor' on 'e6f8993'.
236- (fix conflicts and then run "git rebase --continue")
237- (use "git rebase --skip" to skip this patch)
238- (use "git rebase --abort" to check out the original branch)
239-
240- Unmerged paths:
241- (use "git reset HEAD <file>..." to unstage)
242- (use "git add <file>..." to mark resolution)
243-
244- both modified: lib/matplotlib/backends/backend_gtk3.py
245-
246- no changes added to commit (use "git add" and/or "git commit -a")
247-
248- This tells you exactly where the conflict is and provides some advice
249- on how to proceed. Opening up the file in question, you will see
250- blocks that look something like this::
251-
252- <<<<<<< HEAD
253- =======
254- self.__dict__.clear() # Is this needed? Other backends don't have it.
255- >>>>>>> pep8 clean up on backend_gtk3.py
256-
257- The block of code between `<<<<<<< ` and `======= ` is the code on the
258- target branch (in this case nothing) and the code between `======= `
259- and `>>>>>>> ` is the code on your branch. The rest of the code is the
260- same between the two branches. You need to determine how to resolve the
261- conflict (in this case, the code on HEAD is correct). Once you have
262- resolved all the conflicts, `add ` the file to the index::
263-
264- $ git add lib/matplotlib/backends/backend_gtk3.py
265-
266- Repeat this for all of the files that have conflicts. When you are done with
267- that you can check the status::
268-
269- $ git status
270- rebase in progress; onto e6f8993
271- You are currently rebasing branch 'backend_plt_refactor' on 'e6f8993'.
272- (all conflicts fixed: run "git rebase --continue")
273-
274- Changes to be committed:
275- (use "git reset HEAD <file>..." to unstage)
276-
277- modified: lib/matplotlib/backends/backend_gtk3.py
278-
279- which shows us that we have resolved all of the conflicts with this
280- commit and can continue::
281-
282- $ git rebase --continue
283-
284- You now iterate the until you have made it through all of the commits
285- which have conflicts. Once you have successfully rebased your branch,
286- be sure to re-run the tests to make sure everything is still working
287- properly.
288-
289- Your branch is now rebased, however, because of the way git
290- determines the hash of each commit, it now shares no commits with your
291- old branch published on github so you can not push to that branch as
292- you would when simply adding commits. In order to publish your newly
293- rebased (and tested!) branch you need to use the `--force ` flag::
294-
295- $ git push --force github
296-
297- which will _replace_ all of the commits under your branch on github
298- with the new versions of the commit.
299-
300- Congratulations, you have rebased your branch!
301166
302167
303168Style guide
0 commit comments