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

Skip to content

Commit f519169

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

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
@@ -135,141 +135,6 @@ C/C++ extensions
135135
docstrings, and the Numpydoc format is well understood in the
136136
scientific Python community.
137137

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

274139

275140
Style guide

doc/devel/gitwash/development_workflow.rst

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,142 @@ When you are ready to ask for the merge of your code:
158158
and not master. Github can not automatically determine the branch
159159
to merge into.
160160

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

0 commit comments

Comments
 (0)