Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b3d268f

Browse files
committed
DOC : moved rebase docs -> development_workflow
- this will likely create an annoying conflict, yay
1 parent bb8525e commit b3d268f

File tree

2 files changed

+136
-135
lines changed

2 files changed

+136
-135
lines changed

doc/devel/coding_guide.rst

Lines changed: 0 additions & 135 deletions
Original file line numberDiff line numberDiff line change
@@ -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

303168
Style guide

doc/devel/gitwash/development_workflow.rst

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,142 @@ sure your pull request is ready for merging.
144144
thread.
145145

146146

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

0 commit comments

Comments
 (0)