git-process 1.1.4 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. data/CHANGELOG.md +14 -1
  2. data/LICENSE +193 -22
  3. data/README.md +212 -71
  4. data/man/git-process.1 +371 -0
  5. metadata +52 -140
  6. data/Gemfile +0 -20
  7. data/Gemfile.lock +0 -53
  8. data/Rakefile +0 -16
  9. data/bin/git-new-fb +0 -58
  10. data/bin/git-pull-request +0 -107
  11. data/bin/git-sync +0 -73
  12. data/bin/git-to-master +0 -133
  13. data/git-process.gemspec +0 -25
  14. data/lib/git-process/abstract_error_builder.rb +0 -53
  15. data/lib/git-process/changed_file_helper.rb +0 -115
  16. data/lib/git-process/git_abstract_merge_error_builder.rb +0 -146
  17. data/lib/git-process/git_branch.rb +0 -105
  18. data/lib/git-process/git_branches.rb +0 -73
  19. data/lib/git-process/git_config.rb +0 -153
  20. data/lib/git-process/git_lib.rb +0 -512
  21. data/lib/git-process/git_logger.rb +0 -84
  22. data/lib/git-process/git_merge_error.rb +0 -28
  23. data/lib/git-process/git_process.rb +0 -172
  24. data/lib/git-process/git_process_error.rb +0 -18
  25. data/lib/git-process/git_process_options.rb +0 -99
  26. data/lib/git-process/git_rebase_error.rb +0 -30
  27. data/lib/git-process/git_remote.rb +0 -256
  28. data/lib/git-process/git_status.rb +0 -108
  29. data/lib/git-process/github_configuration.rb +0 -298
  30. data/lib/git-process/github_pull_request.rb +0 -151
  31. data/lib/git-process/new_fb.rb +0 -50
  32. data/lib/git-process/parked_changes_error.rb +0 -41
  33. data/lib/git-process/pull_request.rb +0 -134
  34. data/lib/git-process/pull_request_error.rb +0 -25
  35. data/lib/git-process/rebase_to_master.rb +0 -148
  36. data/lib/git-process/sync.rb +0 -136
  37. data/lib/git-process/uncommitted_changes_error.rb +0 -23
  38. data/lib/git-process/version.rb +0 -22
  39. data/spec/FileHelpers.rb +0 -19
  40. data/spec/GitRepoHelper.rb +0 -123
  41. data/spec/changed_file_helper_spec.rb +0 -127
  42. data/spec/git_abstract_merge_error_builder_spec.rb +0 -126
  43. data/spec/git_branch_spec.rb +0 -123
  44. data/spec/git_config_spec.rb +0 -45
  45. data/spec/git_lib_spec.rb +0 -176
  46. data/spec/git_logger_spec.rb +0 -66
  47. data/spec/git_process_spec.rb +0 -208
  48. data/spec/git_remote_spec.rb +0 -227
  49. data/spec/git_status_spec.rb +0 -122
  50. data/spec/github_configuration_spec.rb +0 -152
  51. data/spec/github_pull_request_spec.rb +0 -96
  52. data/spec/github_test_helper.rb +0 -49
  53. data/spec/new_fb_spec.rb +0 -130
  54. data/spec/pull_request_helper.rb +0 -94
  55. data/spec/pull_request_spec.rb +0 -128
  56. data/spec/rebase_to_master_spec.rb +0 -429
  57. data/spec/spec_helper.rb +0 -21
  58. data/spec/sync_spec.rb +0 -304
data/CHANGELOG.md CHANGED
@@ -1,4 +1,17 @@
1
- # CHANGELOG - 1.1.4 #
1
+ # CHANGELOG - 1.2.0 #
2
+
3
+ ### Since 1.1.4 ###
4
+
5
+ * **Changed git-sync to default to rebasing.** ([GH-112](https://github.com/jdigger/git-process/issues/112))
6
+ * git-sync now can take a branch name to check it out for work ([GH-117](https://github.com/jdigger/git-process/issues/117))
7
+ * Change to use the "native" manpage-based help system for `git help`.
8
+ ([GH-113](https://github.com/jdigger/git-process/issues/113))
9
+ * `git new-fb` now defaults to doing a `git fetch` before creating the feature branch if a remote is defined.
10
+ ([GH-118](https://github.com/jdigger/git-process/issues/118))
11
+ * Removed **--interactive** option from git-to-master
12
+ * Updated README and related files.
13
+ * Retries closing a pull request if it gets a 422. ([GH-102](https://github.com/jdigger/git-process/issues/102))
14
+ * Fixed typo in merge error. ([GH-114](https://github.com/jdigger/git-process/issues/114))
2
15
 
3
16
  ### Since 1.1.3 ###
4
17
 
data/LICENSE CHANGED
@@ -1,22 +1,193 @@
1
- Copyright (c) 2012 Jim Moore
2
-
3
- MIT License
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining
6
- a copy of this software and associated documentation files (the
7
- "Software"), to deal in the Software without restriction, including
8
- without limitation the rights to use, copy, modify, merge, publish,
9
- distribute, sublicense, and/or sell copies of the Software, and to
10
- permit persons to whom the Software is furnished to do so, subject to
11
- the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be
14
- included in all copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1
+ Copyright (c) 2012-2013 Jim Moore
2
+
3
+ Apache License
4
+ Version 2.0, January 2004
5
+ http://www.apache.org/licenses/
6
+
7
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
8
+
9
+ 1. Definitions.
10
+
11
+ "License" shall mean the terms and conditions for use, reproduction, and
12
+ distribution as defined by Sections 1 through 9 of this document.
13
+
14
+ "Licensor" shall mean the copyright owner or entity authorized by the copyright
15
+ owner that is granting the License.
16
+
17
+ "Legal Entity" shall mean the union of the acting entity and all other entities
18
+ that control, are controlled by, or are under common control with that entity.
19
+ For the purposes of this definition, "control" means (i) the power, direct or
20
+ indirect, to cause the direction or management of such entity, whether by
21
+ contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity exercising
25
+ permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications, including
28
+ but not limited to software source code, documentation source, and configuration
29
+ files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical transformation or
32
+ translation of a Source form, including but not limited to compiled object code,
33
+ generated documentation, and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or Object form, made
36
+ available under the License, as indicated by a copyright notice that is included
37
+ in or attached to the work (an example is provided in the Appendix below).
38
+
39
+ "Derivative Works" shall mean any work, whether in Source or Object form, that
40
+ is based on (or derived from) the Work and for which the editorial revisions,
41
+ annotations, elaborations, or other modifications represent, as a whole, an
42
+ original work of authorship. For the purposes of this License, Derivative Works
43
+ shall not include works that remain separable from, or merely link (or bind by
44
+ name) to the interfaces of, the Work and Derivative Works thereof.
45
+
46
+ "Contribution" shall mean any work of authorship, including the original version
47
+ of the Work and any modifications or additions to that Work or Derivative Works
48
+ thereof, that is intentionally submitted to Licensor for inclusion in the Work
49
+ by the copyright owner or by an individual or Legal Entity authorized to submit
50
+ on behalf of the copyright owner. For the purposes of this definition,
51
+ "submitted" means any form of electronic, verbal, or written communication sent
52
+ to the Licensor or its representatives, including but not limited to
53
+ communication on electronic mailing lists, source code control systems, and
54
+ issue tracking systems that are managed by, or on behalf of, the Licensor for
55
+ the purpose of discussing and improving the Work, but excluding communication
56
+ that is conspicuously marked or otherwise designated in writing by the copyright
57
+ owner as "Not a Contribution."
58
+
59
+ "Contributor" shall mean Licensor and any individual or Legal Entity on behalf
60
+ of whom a Contribution has been received by Licensor and subsequently
61
+ incorporated within the Work.
62
+
63
+ 2. Grant of Copyright License.
64
+
65
+ Subject to the terms and conditions of this License, each Contributor hereby
66
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
67
+ irrevocable copyright license to reproduce, prepare Derivative Works of,
68
+ publicly display, publicly perform, sublicense, and distribute the Work and such
69
+ Derivative Works in Source or Object form.
70
+
71
+ 3. Grant of Patent License.
72
+
73
+ Subject to the terms and conditions of this License, each Contributor hereby
74
+ grants to You a perpetual, worldwide, non-exclusive, no-charge, royalty-free,
75
+ irrevocable (except as stated in this section) patent license to make, have
76
+ made, use, offer to sell, sell, import, and otherwise transfer the Work, where
77
+ such license applies only to those patent claims licensable by such Contributor
78
+ that are necessarily infringed by their Contribution(s) alone or by combination
79
+ of their Contribution(s) with the Work to which such Contribution(s) was
80
+ submitted. If You institute patent litigation against any entity (including a
81
+ cross-claim or counterclaim in a lawsuit) alleging that the Work or a
82
+ Contribution incorporated within the Work constitutes direct or contributory
83
+ patent infringement, then any patent licenses granted to You under this License
84
+ for that Work shall terminate as of the date such litigation is filed.
85
+
86
+ 4. Redistribution.
87
+
88
+ You may reproduce and distribute copies of the Work or Derivative Works thereof
89
+ in any medium, with or without modifications, and in Source or Object form,
90
+ provided that You meet the following conditions:
91
+
92
+ You must give any other recipients of the Work or Derivative Works a copy of
93
+ this License; and
94
+ You must cause any modified files to carry prominent notices stating that You
95
+ changed the files; and
96
+ You must retain, in the Source form of any Derivative Works that You distribute,
97
+ all copyright, patent, trademark, and attribution notices from the Source form
98
+ of the Work, excluding those notices that do not pertain to any part of the
99
+ Derivative Works; and
100
+ If the Work includes a "NOTICE" text file as part of its distribution, then any
101
+ Derivative Works that You distribute must include a readable copy of the
102
+ attribution notices contained within such NOTICE file, excluding those notices
103
+ that do not pertain to any part of the Derivative Works, in at least one of the
104
+ following places: within a NOTICE text file distributed as part of the
105
+ Derivative Works; within the Source form or documentation, if provided along
106
+ with the Derivative Works; or, within a display generated by the Derivative
107
+ Works, if and wherever such third-party notices normally appear. The contents of
108
+ the NOTICE file are for informational purposes only and do not modify the
109
+ License. You may add Your own attribution notices within Derivative Works that
110
+ You distribute, alongside or as an addendum to the NOTICE text from the Work,
111
+ provided that such additional attribution notices cannot be construed as
112
+ modifying the License.
113
+ You may add Your own copyright statement to Your modifications and may provide
114
+ additional or different license terms and conditions for use, reproduction, or
115
+ distribution of Your modifications, or for any such Derivative Works as a whole,
116
+ provided Your use, reproduction, and distribution of the Work otherwise complies
117
+ with the conditions stated in this License.
118
+
119
+ 5. Submission of Contributions.
120
+
121
+ Unless You explicitly state otherwise, any Contribution intentionally submitted
122
+ for inclusion in the Work by You to the Licensor shall be under the terms and
123
+ conditions of this License, without any additional terms or conditions.
124
+ Notwithstanding the above, nothing herein shall supersede or modify the terms of
125
+ any separate license agreement you may have executed with Licensor regarding
126
+ such Contributions.
127
+
128
+ 6. Trademarks.
129
+
130
+ This License does not grant permission to use the trade names, trademarks,
131
+ service marks, or product names of the Licensor, except as required for
132
+ reasonable and customary use in describing the origin of the Work and
133
+ reproducing the content of the NOTICE file.
134
+
135
+ 7. Disclaimer of Warranty.
136
+
137
+ Unless required by applicable law or agreed to in writing, Licensor provides the
138
+ Work (and each Contributor provides its Contributions) on an "AS IS" BASIS,
139
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied,
140
+ including, without limitation, any warranties or conditions of TITLE,
141
+ NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A PARTICULAR PURPOSE. You are
142
+ solely responsible for determining the appropriateness of using or
143
+ redistributing the Work and assume any risks associated with Your exercise of
144
+ permissions under this License.
145
+
146
+ 8. Limitation of Liability.
147
+
148
+ In no event and under no legal theory, whether in tort (including negligence),
149
+ contract, or otherwise, unless required by applicable law (such as deliberate
150
+ and grossly negligent acts) or agreed to in writing, shall any Contributor be
151
+ liable to You for damages, including any direct, indirect, special, incidental,
152
+ or consequential damages of any character arising as a result of this License or
153
+ out of the use or inability to use the Work (including but not limited to
154
+ damages for loss of goodwill, work stoppage, computer failure or malfunction, or
155
+ any and all other commercial damages or losses), even if such Contributor has
156
+ been advised of the possibility of such damages.
157
+
158
+ 9. Accepting Warranty or Additional Liability.
159
+
160
+ While redistributing the Work or Derivative Works thereof, You may choose to
161
+ offer, and charge a fee for, acceptance of support, warranty, indemnity, or
162
+ other liability obligations and/or rights consistent with this License. However,
163
+ in accepting such obligations, You may act only on Your own behalf and on Your
164
+ sole responsibility, not on behalf of any other Contributor, and only if You
165
+ agree to indemnify, defend, and hold each Contributor harmless for any liability
166
+ incurred by, or claims asserted against, such Contributor by reason of your
167
+ accepting any such warranty or additional liability.
168
+
169
+ END OF TERMS AND CONDITIONS
170
+
171
+ APPENDIX: How to apply the Apache License to your work
172
+
173
+ To apply the Apache License to your work, attach the following boilerplate
174
+ notice, with the fields enclosed by brackets "{}" replaced with your own
175
+ identifying information. (Don't include the brackets!) The text should be
176
+ enclosed in the appropriate comment syntax for the file format. We also
177
+ recommend that a file or class name and description of purpose be included on
178
+ the same "printed page" as the copyright notice for easier identification within
179
+ third-party archives.
180
+
181
+ Copyright {yyyy} {name of copyright owner}
182
+
183
+ Licensed under the Apache License, Version 2.0 (the "License");
184
+ you may not use this file except in compliance with the License.
185
+ You may obtain a copy of the License at
186
+
187
+ http://www.apache.org/licenses/LICENSE-2.0
188
+
189
+ Unless required by applicable law or agreed to in writing, software
190
+ distributed under the License is distributed on an "AS IS" BASIS,
191
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
192
+ See the License for the specific language governing permissions and
193
+ limitations under the License.
data/README.md CHANGED
@@ -11,14 +11,30 @@ See the F.A.Q. for a much more complete explanation for the thoughts and assumpt
11
11
 
12
12
  ## Unix-based OS (OSX, Linux, etc.) Installation ##
13
13
 
14
- $ sudo gem install git-process
14
+ If you are using a Ruby sandboxing system like [RVM](https://rvm.io/) or [rbenv](https://github.com/sstephenson/rbenv)
15
+ (either or which I would recommend) then simply do:
15
16
 
16
- Some older operating systems (such as OSX 10.6) are using an old version of RubyGems, which can cause installation problems. Do "`sudo gem update --system`" to fix.
17
+ $ gem install git-process
18
+
19
+ If you are not using RVM or rbenv, you will likely need to precede that with "`sudo`".
20
+
21
+ Some older operating systems (such as OSX 10.6) are using an old version of RubyGems, which can cause installation problems. Do "`gem update --system`" to fix.
17
22
 
18
23
  ## Windows Installation ##
19
24
 
20
- 1. Install Ruby (if you have not sone so already) from http://rubyinstaller.org/
25
+ 1. Install Ruby (if you have not done so already) from http://rubyinstaller.org/
26
+ * If it complains about not being able to compile native code, install [DevKit](http://rubyinstaller.org/downloads).
27
+ * See [this StackOverflow](http://stackoverflow.com/questions/8100891/the-json-native-gem-requires-installed-build-tools/8463500#8463500) for help.
21
28
  2. Open a command prompt and type `gem install git-process`
29
+ 3. *THERE IS A KNOWN PROBLEM WITH [HELP ON WINDOWS](https://github.com/jdigger/git-process/issues/120).*
30
+
31
+ ## All Operating Systems ##
32
+
33
+ To get full `git help` and manpage support, do:
34
+
35
+ $ git config --global man.gem-man.cmd "gem man -s"
36
+ $ git config --global man.viewer gem-man
37
+ $ alias man="gem man -s"
22
38
 
23
39
 
24
40
  # Overview #
@@ -33,68 +49,11 @@ Some older operating systems (such as OSX 10.6) are using an old version of Ruby
33
49
  ## Command List ##
34
50
 
35
51
  * `git new-fb` - Create a new feature branch based on the integration branch.
36
- * `git sync` - Gets the latest changes that have happened on the integration branch, then pushes your changes to a "private" branch on the server.
37
- * `git pull-request` - Creates a Pull Request for the current branch.
52
+ * `git sync` - Gets the latest changes that have happened on the integration branch and remote feature branch, then pushes your changes to a feature branch on the server.
53
+ * `git pull-request` - Create or get a Pull Request for the current branch.
38
54
  * `git to-master` - Rebase against the integration branch, then pushes to it. Knows how to deal "intelligently" with pull-requests.
39
55
 
40
- **All commands are well documented within themselves: Use the "-h" switch to see the full documentation.** (e.g., "`git sync -h`")
41
-
42
-
43
- # Workflow #
44
-
45
- _The following assumes that the integration branch is "origin/master"._
46
-
47
- ## Code Review Using Pull Requests ##
48
-
49
- 1. When starting work on a new feature, use "`git new-fb feature-name`".
50
- * This creates a new branch called "`feature-name`" based on "`origin/master`".
51
- 2. After making some changes, if you want to pick up any changes other people have made, as well
52
- as save your work on the server, do "`git sync`".
53
- * That will merge in the changes that have occurred in "`origin/master`" and then push the
54
- result to the "`feature_branch`" branch to the server.
55
- 3. When you feel your work is ready for others to look at, do "`git pull-request`" to ask someone to review your changes.
56
- * If no name or number is provided, it is assumed that you want to create a new pull request with the same name as the current branch.
57
- * Any changes you make via "`git sync`" are automatically reflected in the pull request.
58
- 4. As a reviewer, to see a pull-request, do "`git pull-request ##`" (where "##" is the pull request number) to check
59
- out the branch associated with the pull request in your repository.
60
- 5. If you get the thumbs up from the code-review, use "`git to-master`".
61
- * This will merge and push your changes into "`origin/master`", closing the pull request.
62
- * If reviewing the pull request via the web interface was sufficient, or there is otherwise not a reason
63
- to explicitly checkout the branch first, you can use "`git to-master`" with the pull request number to
64
- combine both of these steps.
65
- 5. If you still need to make changes, do so and use "`git sync`" to keep your branch on the
66
- server for that feature updated with your work until all issues have been resolved.
67
-
68
- ```
69
- $ git new-fb my-feature # 1
70
- # do work # 2
71
- $ git commit # 3
72
- $ git sync # 4
73
- # repeat #2-#4 as necessary # 5
74
- $ git pull-request # 6
75
- # repeat #2-#4 as necessary # 7
76
- $ git to-master # 8
77
- ```
78
-
79
- ## Working Alone or When Pairing ##
80
-
81
- 1. When starting work on a new feature, use "`git new-fb feature-name`".
82
- * This creates a new branch called "`feature-name`" based on "`origin/master`".
83
- 2. After making some changes, if you want to pick up any changes other people have made, as well
84
- as save your work on the server, do "`git sync`".
85
- * That will merge in the changes that have occurred in "`origin/master`" and then push the
86
- result to the "`feature_branch`" branch to the server.
87
- 3. When you are ready to merge your work into the mainline, "`git to-master`".
88
- * This will merge and push your changes into "`origin/master`"
89
-
90
- ```
91
- $ git new-fb my-feature # 1
92
- # do work # 2
93
- $ git commit # 3
94
- $ git sync # 4
95
- # repeat #2-#4 as necessary # 5
96
- $ git to-master # 6
97
- ```
56
+ **All commands are well documented within themselves: Use the "git help" to see the full documentation.** (e.g., "`git help sync`")
98
57
 
99
58
 
100
59
  ## Configurables ##
@@ -104,7 +63,7 @@ $ git to-master # 6
104
63
  * `gitProcess.integrationBranch` : The name of the integration branch. Defaults to `master`, but can be set to `develop` or other.
105
64
  * `gitProcess.keepLocalIntegrationBranch` : Controls asking about removing the local integration branch. Defaults to 'false' (i.e., do not assume the branch should be there).
106
65
  * `gitProcess.remoteName` : Explicitly sets the remote server name to use.
107
- * `gitProcess.defaultRebaseSync`: Should `git sync` default to using rebase instead of merge?
66
+ * `gitProcess.defaultRebaseSync`: Should `git sync` default to using rebase instead of merge? Defaults to 'true' (i.e., Sync using rebase.)
108
67
 
109
68
 
110
69
  # Assumptions #
@@ -114,7 +73,7 @@ $ git to-master # 6
114
73
  * "`git sync`" makes it extremely easy for you to get any changes that are made in "`master`" into your branch so you can react to it immediately.
115
74
  * "`git to-master`" then makes it easy to cleanly integrate the changes you have made. If you need to keep the current branch open, use the `--keep` option. Otherwise it closes the branch along with various other house-keeping duties.
116
75
  * The process that you use should be essentially the same, regardless of whether you are working alone, or on a large distributed team.
117
- * The exception here is "`git pull-request`" since you do not use pull requests when working solo or when pair-programming.
76
+ * The exception here is "`git pull-request`" since you typically do not use pull requests when working solo or when pair-programming.
118
77
 
119
78
 
120
79
  # Notes #
@@ -123,11 +82,191 @@ $ git to-master # 6
123
82
  * If there is a problem (such as a merge conflict), this will try to resolve such errors for you as much as it can do safely. When it can't do so in an automated way, it will try to tell you the process for doing so manually.
124
83
  * The first time you use a GitHub feature (e.g., "`git pull-request`"), this will ask for your username and password. It does not store them, but instead uses them to get an OAuth2 token, which is stored in "`git config gitProcess.github.authToken`".
125
84
  * If you want to use a different integration branch other than "`master`", set the "`gitProcess.integrationBranch`" configuration value. (e.g., "`git config gitProcess.integrationBranch my-integ-branch`")
126
- * This tries to respond "intelligently" to the use of 'rerere'.
127
85
  * By default the first server name reported by `git remote` is used as the server/remote name. Since most projects only have a single remote (i.e., "origin") this works most of the time. But if you have multiple remotes and want to explicitly set it, use the `gitProcess.remoteName` configuration option.
128
86
  * `git pull-request` shows the URL for the pull request after creating it on the server. Most terminal programs let you click on it to open it in your browser. (e.g., Cmd-Click on OSX.)
129
87
 
130
88
 
89
+ # Workflow Examples #
90
+
91
+ ## Working Alone On A Local-Only Project ##
92
+
93
+ Jim is working on "my_project" and needs to start work on a new feature.
94
+
95
+ ```
96
+ [a_branch]$ git new-fb save_the_planet
97
+ Creating save_tp off of master
98
+ [save_the_planet]$
99
+ ```
100
+
101
+ He does lots of work. Checkin, checkin, checkin.
102
+
103
+ A sudden new brilliant idea happens.
104
+
105
+ ```
106
+ [save_the_planet]$ git new-fb shave_the_bunnies
107
+ Creating shave_the_bunnies off of master
108
+ [shave_the_bunnies]$
109
+ ```
110
+
111
+ After creating a Sheering class and tests, he commits his changes.
112
+
113
+ ```
114
+ [shave_the_bunnies]$ git commit
115
+ [shave_the_bunnies]$ git to-master
116
+ Rebasing shave_the_bunnies against master
117
+ Removing branch 'shave_the_bunnies'
118
+ [_parking_]$
119
+ ```
120
+
121
+ Time to get back to work on "save_the_planet".
122
+
123
+ ```
124
+ [_parking_]$ git checkout save_the_planet
125
+ [save_the_planet]$ git sync
126
+ Rebasing save_the_planet against master
127
+ [save_the_planet]$
128
+ ```
129
+
130
+ Do more work. Commit. Commit. Commit.
131
+
132
+ ```
133
+ [save_the_planet]$ git sync
134
+ Rebasing save_the_planet against master
135
+ [save_the_planet]$
136
+ ```
137
+
138
+ Liking to have a clean history, he squashes and edits the commits to hide
139
+ the evidence of false starts and stupid ideas so that anyone who sees the
140
+ code in the future will think he was simply a genius.
141
+
142
+ ```
143
+ [save_the_planet]$ git rebase -i
144
+ Rebasing save_the_planet against master
145
+ [save_the_planet]$ git to-master
146
+ Rebasing save_the_planet against master
147
+ Removing branch 'save_the_planet'
148
+ [_parking_]$
149
+ ```
150
+
151
+ Time to release to a grateful world.
152
+
153
+
154
+ ## Working With A Team ##
155
+
156
+ John, Alice, Bill and Sally are working on "big_monies." Alice and John are pairing and
157
+ need to start work on a new feature.
158
+
159
+ ```
160
+ john-[a_branch]$ git new-fb steal_underpants
161
+ Fetching the latest changes from the server
162
+ Creating steal_underpants off of origin/master
163
+ john-[steal_underpants]$
164
+ ```
165
+
166
+ They do lots of work. Checkin, checkin, checkin. It has a lot of steps...
167
+
168
+ Meanwhile Bill has been working on his great idea:
169
+
170
+ ```
171
+ bill-[some_branch]$ git new-fb awesomo4000
172
+ Fetching the latest changes from the server
173
+ Creating awesomo4000 off of origin/master
174
+ bill-[awesomo4000]$
175
+ ```
176
+
177
+ He creates his "Laaaaame" class and checks it in, with a pull request asking Sally to do a code review.
178
+
179
+ ```
180
+ bill-[awesomo4000]$ git commit
181
+ bill-[awesomo4000]$ git pull-request "A.W.E.S.O.M-0 4000 prototype" \
182
+ -d "@sally, can you make sure Butters won't recognize it?"
183
+ Pushing to 'awesomo4000' on 'origin'.
184
+ Creating a pull request asking for 'awesomo4000' to be merged into 'master' on big_monies.
185
+ Created pull request at https://github.com/big_monies/pull/3454
186
+ bill-[awesomo4000]$
187
+ ```
188
+
189
+ Sally sees the email. After looking at it in the web interface, she wants to test it.
190
+
191
+ ```
192
+ sally-[other_branch]$ git pull-request 3454
193
+ Getting #pr_number
194
+ Fetching the latest changes from the server
195
+ new branch: awesomo4000
196
+ Setting upstream/tracking for branch 'awesomo4000' to 'origin/master'.
197
+ sally-[awesomo4000]$ git sync
198
+ Fetching the latest changes from the server
199
+ Rebasing awesomo4000 against origin/master
200
+ Pushing to 'awesomo4000' on 'origin'.
201
+ sally-[awesomo4000]$
202
+ ```
203
+
204
+ After verifying that the tests still work and "it's all good" she promotes the code to integration.
205
+
206
+ ```
207
+ sally-[awesomo4000]$ git to-master
208
+ Fetching the latest changes from the server
209
+ Rebasing awesomo4000 against origin/master
210
+ Pushing to 'awesomo4000' on 'origin'.
211
+ Removing branch remote 'awesomo4000'
212
+ Removing branch local 'awesomo4000'
213
+ Closing a pull request #3454 on origin.
214
+ sally-[_parking_]$
215
+ ```
216
+
217
+ Over lunch Alice gets a brainstorm ("a duck and rubber hose!") and rushes off to her computer:
218
+
219
+ ```
220
+ alice-[lens_cap]$ git sync steal_underpants
221
+ Fetching the latest changes from the server
222
+ Creating steal_underpants off of origin/steal_underpants
223
+ Setting upstream/tracking for branch 'steal_underpants' to 'origin/master'.
224
+ alice-[steal_underpants]$
225
+ ```
226
+
227
+ She makes her changes, syncs back up with the server, and heads over to pair with John again.
228
+
229
+ ```
230
+ alice-[steal_underpants]$ git commit
231
+ alice-[steal_underpants]$ git sync
232
+ Fetching the latest changes from the server
233
+ Rebasing steal_underpants against origin/master
234
+ Pushing to 'steal_underpants' on 'origin'.
235
+ alice-[steal_underpants]$
236
+ ```
237
+
238
+ John, meanwhile, had made some changes of his own.
239
+
240
+ ```
241
+ john-[steal_underpants]$ git commit
242
+ john-[steal_underpants]$ git sync
243
+ Fetching the latest changes from the server
244
+ Remote branch has changed
245
+ Rebasing steal_underpants against origin/steal_underpants
246
+ Rebasing steal_underpants against origin/master
247
+ Pushing to 'steal_underpants' on 'origin'.
248
+ john-[steal_underpants]$
249
+ ```
250
+
251
+ At this point, his local branch has Alice's change as well as Bill and
252
+ Sally's A.W.E.S.O.M-O 4000 enhancements.
253
+
254
+ After confirming with Alice and Bill that everything looks good, he
255
+ pushes his changes up for integration.
256
+
257
+ ```
258
+ john-[steal_underpants]$ git to-master
259
+ Fetching the latest changes from the server
260
+ Rebasing steal_underpants against origin/master
261
+ Pushing to 'steal_underpants' on 'origin'.
262
+ Removing remote branch 'steal_underpants'
263
+ Removing local branch 'steal_underpants'
264
+ [_parking_]$
265
+ ```
266
+
267
+ Profit!!
268
+
269
+
131
270
  # F.A.Q. #
132
271
 
133
272
  ## Q: How is this different from git-flow or GitHub flow? ##
@@ -142,14 +281,14 @@ $ git to-master # 6
142
281
  Branches are extremely powerful tools that allow for clean organization/modularization of development.
143
282
 
144
283
  * Branches make it easy to sandbox changes while they are in a state of flux, while at the same time allowing you to be very fearless about making potentially breaking changes.
145
- * For example, I commit "green to green": Doing [TDD](http://en.wikipedia.org/wiki/Test-driven_development), I commit every time I have a newly passing test case. So, assuming I'm in a regular development flow, I'm committing my changes every five minutes. Tiny commits, but lots of them. What that means is that if I make a "less than wise choice" at some point, it's trivial to rewind to before I'd made the mistake, potentially keep the throw-away code in another branch while I do my cleanup, and generally use the full power of a revision control system to make my life safer and easier. The branch(es) are pretty chaotic, but that's not a problem because before integrating with the mainline, I take a moment to cleanup: Squash related commits together, write clearer commit messages (since now I know what "the answer" is), and generally move from my drafts to a more finished result. (See below on objections related to "lying with rebase.") That may just be me, though, because I'm very paranoid when it comes to computers. I tend to automatically hit Cmd/Ctl-S every time I type a period when I'm writing, or when I close a block when I'm programming. I have a minimum of three copies/backups around the world of all my important documents. And I "`git sync`" frequently to make sure my machine isn't the only place where all my hard work is being stored. Have I mentioned I don't trust computers?
284
+ * For example, I commit "green to green": Doing [TDD](http://en.wikipedia.org/wiki/Test-driven_development), I commit every time I have a newly passing test case. So, assuming I'm in a regular development flow, I'm committing my changes every five minutes or so. Tiny commits, but lots of them. What that means is that if I make a "less than wise choice" at some point, it's trivial to rewind to before I'd made the mistake, potentially keep the throw-away code in another branch while I do my cleanup, and generally use the full power of a revision control system to make my life safer and easier. The branch(es) are pretty chaotic, but that's not a problem because before integrating with the mainline, I take a moment to cleanup: Squash related commits together, write clearer commit messages (since now I know what "the answer" is), and generally move from my drafts to a more finished result. (See below on objections related to "lying with rebase.") That may just be me, though, because I'm very paranoid when it comes to computers. I tend to automatically hit Cmd/Ctl-S every time I type a period when I'm writing, or when I close a block when I'm programming. I have a minimum of three copies/backups around the world of all my important documents. And I "`git sync`" frequently to make sure my machine isn't the only place where all my hard work is being stored. Have I mentioned I don't trust computers?
146
285
 
147
286
  * Branches allow for focused collaboration. Because a branch is about exactly one thing, it means that a team can collaborate around a feature/bug (especially when used in conjunction with a "pull request"), and keep such changes sandboxed until such time that they are ready to bring a larger audience into the mix.
148
- * Branches encourage being less "shy" about your code. I have heard, on a number of occasions, developers say "I'm not ready to push this to the server yet because [it's still rough (and embarrassing)]/[it may break other people]/etc." All of those reasons for "hoarding" code are moot with branches.
287
+ * Branches encourage being less "shy" about your code. I have heard, on a number of occasions, developers say "I'm not ready to push this to the server yet because \[it's still rough (and embarrassing)]/\[it may break other people]/etc." All of those reasons for "hoarding" code are moot with branches.
149
288
 
150
289
  Jez Humble, a brilliant Principle at ThoughtWorks Studios, talks a lot about how "branches are evil." Unfortunately, people hear that, know how smart he is, and simply repeat it without really understanding what his objections are. Fortunately, he [posted clarification about what's really meant by that](http://continuousdelivery.com/2011/07/on-dvcs-continuous-integration-and-feature-branches/). He essentially says that the problem is that developers abuse branches by not merging with mainline (i.e., "master") on a regular basis. Not constantly getting changes *from* mainline makes life rough when it comes time to integrate. Not putting your changes *into* mainline means that your changes are not being validated (via [Continuous Integration](http://martinfowler.com/articles/continuousIntegration.html), or -- better -- with [Continuous Delivery](http://continuousdelivery.com/)). Both are, in fact, sins akin to not doing automated testing.
151
290
 
152
- Making it "easier to do things right than wrong" (i.e., using branches and keeping them synced with mainline) was the primary motivation for this project. This should be especially evident in the "`git sync`" and "`git to-master`" commands.
291
+ Making it "easier to do things right than wrong" (i.e., using branches and keeping them synced with mainline) was the primary motivation for this project. Every command here is focussed on making it trivial to use branches that stay in sync with mainline and encourage collaboration.
153
292
 
154
293
 
155
294
  ## Q: Why so much emphasis on rebasing? Isn't rebasing a dangerous lie? ##
@@ -158,11 +297,13 @@ Like any powerful tool, "`git rebase`" is "dangerous" if used incorrectly, just
158
297
 
159
298
  [A famous article](http://paul.stadig.name/2010/12/thou-shalt-not-lie-git-rebase-ammend.html) that people have been parroting in various forms for a while makes the case that rebasing (and its various forms, such as squashing, amending commits, etc.) is a "lie." As with so many things, context is everything.
160
299
 
161
- You almost certainly should *not* rebase things that you have "published." Generally this really means "Don't rebase the 'master' branch!" Fortunately, these scripts make it impossible to rebase the mainline by accident. By default "`git sync`" uses "merge" instead of "rebase" to encourage collaboration. (Though you can easily use "-r" if you know no one else is working on the branch.) When it's time to actually merge your work into the mainline (and thus no one is working against it except in the context of mainline), that's when it gets rebased in.
300
+ You almost certainly should *not* rebase things that you have "published." Generally this really means "Don't rebase the 'master' branch!" Fortunately, these scripts make it impossible to rebase the mainline by accident.
162
301
 
163
302
  Rebasing "your" code is an extremely useful way of communicating clearly. In the "green to green" scenario above about branches, a lot of noise is generated. If someone wants to review my code, or cherry-pick in my changes, it's too much of a mess to effectively do so. Also, as part of the process of squashing, I have the opportunity to write clearer commit message based upon my newly enhanced understanding. The intermediate commits were my "drafts" and I'm now submitting my cleaned up copy.
164
303
 
165
- If you have ever seen an "active" project that uses a process like "git-flow" that encourages a lot of branching and merging, you've seen how hard it can be to follow a particular line of development. Branch lines are flying around everywhere, and half the commits are pretty much pure noise. (e.g., "Merge branch 'develop' of ... into develop".) It's also hard to follow the order in which commits actually impacted the mainline. In many ways, in practice merges turn into "a truth effectively being a lie (because it's buried in the noise)" versus rebases that are "a lie (changed from it's 'original' form) to tell an effective truth (clean and very clear about its impact)."
304
+ If you have ever seen an "active" project that uses a process like "git-flow" that encourages a lot of branching and merging, you've seen how hard it can be to follow a particular line of development. Branch lines are flying around everywhere, and half the commits are pretty much pure noise. (e.g., "Merge branch 'master' of ... into master".) It's also hard to follow the order in which commits actually impacted the mainline. In many ways, in practice merges turn into "a truth effectively being a lie" (because it's buried in the noise) versus rebases that are "a lie (changed from it's 'original' form) to tell an effective truth" (clean and very clear about its impact).
305
+
306
+ One significant advantage of using automation like this is that it lets you have the best of both worlds. For example, "`git sync`" uses "rebase" instead of "merge" in a way to is completely safe for collaboration on the same branch. As long as the other people are also using "`git sync`", it will make sure that changes are automatically incorporated with and brought in line. (See the extensive test suite in "`sync_spec.rb`" if you want to see how this works.)
166
307
 
167
308
  This project is trying to promote clear communication about reality as it applies to the code, over micro-management over no-longer-relevant history. Thus rational for the judicious use of rebase.
168
309