Skip to content

Commit dca1ee4

Browse files
committed
contributing: commiter git FAQ
Describe in details how our current git flow works and could be used. Fix #67 Reviewed-By: Ben Noordhuis <[email protected]> PR-URL: #68
1 parent 71e9d0f commit dca1ee4

File tree

1 file changed

+107
-3
lines changed

1 file changed

+107
-3
lines changed

CONTRIBUTING.md

Lines changed: 107 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,10 @@ Okay, so you have decided on the proper branch. Create a feature branch
6161
and start hacking:
6262

6363
```sh
64-
$ git checkout -b my-feature-branch -t origin/v0.10
64+
$ git checkout -b my-feature-branch -t origin/v0.12
6565
```
6666

67-
(Where v0.10 is the latest stable branch as of this writing.)
67+
(Where v0.12 is the latest stable branch as of this writing.)
6868

6969

7070
### COMMIT
@@ -113,7 +113,7 @@ Use `git rebase` (not `git merge`) to sync your work from time to time.
113113

114114
```sh
115115
$ git fetch upstream
116-
$ git rebase upstream/v0.10 # or upstream/master
116+
$ git rebase upstream/v0.12 # or upstream/master
117117
```
118118

119119

@@ -214,6 +214,110 @@ expertise to take full responsibility for the change, according to the
214214
contained. Meaning, every commit should pass all tests. This makes
215215
it much easier when bisecting to find a breaking change.
216216

217+
### Direct instruction
218+
219+
(Optional) Ensure that you are not in a borked `am`/`rebase` state
220+
221+
```sh
222+
git am --abort
223+
git rebase --abort
224+
```
225+
226+
Checkout proper target branch
227+
228+
```sh
229+
git checkout v0.12
230+
```
231+
232+
Update the tree
233+
234+
```sh
235+
git fetch origin
236+
git merge --ff-only origin/v0.12
237+
```
238+
239+
Apply external patches
240+
241+
```sh
242+
curl https://github.com/iojs/io.js/pull/xxx.patch | git am --whitespace=fix
243+
```
244+
245+
Check and re-review the changes
246+
247+
```sh
248+
git diff origin/v0.12
249+
```
250+
251+
Check number of commits and commit messages
252+
253+
```sh
254+
git log origin/v0.12...v0.12
255+
```
256+
257+
If there are multiple commits that relate to the same feature or
258+
one with a feature and separate with a test for that feature -
259+
you'll need to squash them (or strictly speaking `fixup`).
260+
261+
```sh
262+
git rebase -i origin/v0.12
263+
```
264+
265+
This will open a screen like this (in the default shell editor):
266+
267+
```sh
268+
pick 6928fc1 crypto: add feature A
269+
pick 8120c4c add test for feature A
270+
pick 51759dc feature B
271+
pick 7d6f433 test for feature B
272+
273+
# Rebase f9456a2..7d6f433 onto f9456a2
274+
#
275+
# Commands:
276+
# p, pick = use commit
277+
# r, reword = use commit, but edit the commit message
278+
# e, edit = use commit, but stop for amending
279+
# s, squash = use commit, but meld into previous commit
280+
# f, fixup = like "squash", but discard this commit's log message
281+
# x, exec = run command (the rest of the line) using shell
282+
#
283+
# These lines can be re-ordered; they are executed from top to bottom.
284+
#
285+
# If you remove a line here THAT COMMIT WILL BE LOST.
286+
#
287+
# However, if you remove everything, the rebase will be aborted.
288+
#
289+
# Note that empty commits are commented out
290+
```
291+
292+
Replace a couple of `pick`s with `fixup` to squash them into a previous commit:
293+
294+
```sh
295+
pick 6928fc1 crypto: add feature A
296+
fixup 8120c4c add test for feature A
297+
pick 51759dc feature B
298+
fixup 7d6f433 test for feature B
299+
```
300+
301+
Replace `pick` with `reword` to change the commit message:
302+
303+
```sh
304+
reword 6928fc1 crypto: add feature A
305+
fixup 8120c4c add test for feature A
306+
reword 51759dc feature B
307+
fixup 7d6f433 test for feature B
308+
```
309+
310+
Save the file and close the editor, you'll be asked to enter new commit message
311+
for that commit, and everything else should go smoothly. Note that this is a
312+
good moment to fix incorrect commit logs, ensure that they are properly
313+
formatted, and add `Reviewed-By` line.
314+
315+
Time to push it:
316+
317+
```sh
318+
git push origin v0.12
319+
```
320+
217321
# Governance
218322

219323
This repository is jointly governed by a technical committee, commonly

0 commit comments

Comments
 (0)