The gitworkflows(7) illustrated

178
The gitworkflows(7) illustrated by K. Tateishi (@ktateish)

description

gitworkflows(7) is a set of workflow used by git.git. These slides will show you how it works with simple commit graphs.

Transcript of The gitworkflows(7) illustrated

Page 1: The gitworkflows(7) illustrated

The gitworkflows(7)illustrated

by K. Tateishi(@ktateish)

Page 2: The gitworkflows(7) illustrated

What’s gitworkflows?

A set of workflows used in the Git project itself.

Details are described in the online manual gitworkflows(7) shipped with Git.

Page 3: The gitworkflows(7) illustrated

Why gitworkflows?

● You can push -f for integration branches● You can merge topic branches casually● You can keep master stable with clear

history● Scalable to a large number of developersYou know you can freely modify your commits and topic branches with Git. You can do it for integration branches with gitworkflows.

Page 4: The gitworkflows(7) illustrated

In these slides

I’ll show you how gitworkflows* work with simple commit graphs.It helps you to understand gitworkflows even though they are little complicated.

Here we go.* Maybe slightly different from actual workflows used by git.git, because these slides are based on my interpretation of the gitworkflows(7).

Page 5: The gitworkflows(7) illustrated

There is an initial commit.Let’s start from here.

Page 6: The gitworkflows(7) illustrated

master

This is the ‘master’ branch

Page 7: The gitworkflows(7) illustrated

This is the ‘master’ branch

Page 8: The gitworkflows(7) illustrated

Say you need three topics (A, B, C) for the first release.

A

B

C

Page 9: The gitworkflows(7) illustrated

Grow them...

A

B

C

Page 10: The gitworkflows(7) illustrated

And they’ve done.Integrate to master?

Page 11: The gitworkflows(7) illustrated

No. ‘master’ can’t be reset after topics once merged (and pushed to public repositories).Use a ‘throw-away’ integration branch instead.

Page 12: The gitworkflows(7) illustrated

‘pu’ is the name of the throw-away integration branch.Stands for ‘Proposed Update’

pu

Page 13: The gitworkflows(7) illustrated

‘pu’ should be branched from the tip of the most advanced non-throw-away branch.‘master’ would be fine at this time.(You may use git branch pu master)

Page 14: The gitworkflows(7) illustrated

Merge topic A…(checkout pu and merge topic-A. You can use --no-ff merge like below if you want)

merge

Page 15: The gitworkflows(7) illustrated

Merge topic A, B...

merge

Page 16: The gitworkflows(7) illustrated

Merge topic A, B and C into ‘pu’.

merge

Page 17: The gitworkflows(7) illustrated

Then, let’s do tests especially about interactions among the merged topics/features. (They can’t be tested on each branch)

Page 18: The gitworkflows(7) illustrated

BTW you can push ‘pu’ to public repositories if needed.(push origin pu)e.g. a CI server is watching a public repository for running automated tests and you want to push for it.

Page 19: The gitworkflows(7) illustrated

You may find some bugs/lacks of functionalities on ‘pu’ with integrated state of the three topics.

Page 20: The gitworkflows(7) illustrated

One of them was introduced on topic ASo fix it on that topic.

commit

Page 21: The gitworkflows(7) illustrated

Others should be added/fixed on each branch.

commit

Page 22: The gitworkflows(7) illustrated

And merge them into ‘pu’?No.‘pu’ is a throw-away integration branch.

Page 23: The gitworkflows(7) illustrated

So reset ‘pu’ to ‘master’(checkout pu and reset --hard master)

reset

Page 24: The gitworkflows(7) illustrated

So reset ‘pu’ to ‘master’ so that throw away the old ‘pu’.(checkout pu and reset --hard master)

Page 25: The gitworkflows(7) illustrated

And then, re-do merges...

merge

Page 26: The gitworkflows(7) illustrated

And then, re-do merges...

merge

Page 27: The gitworkflows(7) illustrated

And then, re-do merges...

merge

Page 28: The gitworkflows(7) illustrated

Now you’ve got new ‘pu’ that cleanly merged three topics.

Page 29: The gitworkflows(7) illustrated

Note that all developers involved including you can’t work on ‘pu’. All topics have to be forked off from ‘master’

Page 30: The gitworkflows(7) illustrated

Without reset, resulting branch / commit graph would be little more complicated, even though they have identical trees.

trees of these two commits are identical

- with reset

- without reset

Page 31: The gitworkflows(7) illustrated

OK. Let’s push new ‘pu’ to public repositories and test it.

Page 32: The gitworkflows(7) illustrated

You have to do push -f origin pu or push origin +pu if you’ve pushed old ‘pu’ before, because new ‘pu’ isn’t direct descendant of the old ‘pu’ on origin.

Page 33: The gitworkflows(7) illustrated

After test, you found that two features from topic A, B were good and stable but one from topic C wasn’t.

Page 34: The gitworkflows(7) illustrated

You decide to merge topic A and B into ‘master’ because they are stable enough.

Page 35: The gitworkflows(7) illustrated

Merge topic A…(checkout master and merge topic-A)

merge

Page 36: The gitworkflows(7) illustrated

Merge topic A and B into ‘master’.

merge

Page 37: The gitworkflows(7) illustrated

# Now topic A, B are not important any more for these slides. # So gray out them.

Page 38: The gitworkflows(7) illustrated

At the same time, a bug on topic C was spotted and fixed.Let’s rebuild ‘pu’.

commit

Page 39: The gitworkflows(7) illustrated

‘pu’ should be reset to ‘master’ again. (checkout pu and reset --hard master)

reset

Page 40: The gitworkflows(7) illustrated

Resetting ‘pu’ also means that throwing away the old ‘pu’.

Page 41: The gitworkflows(7) illustrated

And then...

Page 42: The gitworkflows(7) illustrated

Merge topic C, then push ‘master’ and ‘pu’. Again, you have to use forced push for ‘pu’, so you may say: git push origin master +pu(prefix ‘+’ for the branch name means forced push.)

merge

Page 43: The gitworkflows(7) illustrated

You want more time to stabilize topic C.So you decide to make the first release with two features already merged into ‘master’.

Page 44: The gitworkflows(7) illustrated

For making release, tag an annotated tag ( ) at ‘master’

tag

Page 45: The gitworkflows(7) illustrated

v1.0.0

The release tag name is ‘v1.0.0’Then push it.(tag -a ‘v1.0.0’ master and push origin v1.0.0)

tag

Page 46: The gitworkflows(7) illustrated

v1.0.0 was released.

v1.0.0

Page 47: The gitworkflows(7) illustrated

You received new topics created after release. They would be branched from ‘master’.

new topics

Page 48: The gitworkflows(7) illustrated

Some new topics would be good but some are possibly not good (i.e. break something).

Page 49: The gitworkflows(7) illustrated

So new topics should be merged into ‘pu’ first.

merge

Page 50: The gitworkflows(7) illustrated

Merge another topic into ‘pu’ and push it.

merge

Page 51: The gitworkflows(7) illustrated

You find two of three active topic branches look good after tests. But you are unsure for...

Good

Good

Page 52: The gitworkflows(7) illustrated

Unsure for: - Stability of the implementation- Excellence of the design- Requirement of the featureetc.

Page 53: The gitworkflows(7) illustrated

It means that keeping them in ‘pu’ is tiring because they won’t be changed for a while, but merging them into ‘master’ can’t be done because they may be changed or possibly deleted.

Page 54: The gitworkflows(7) illustrated

In other words, you need an integration branch for stabilizing, testing or previews for those topics.

Page 55: The gitworkflows(7) illustrated

‘next’ is the integration branch for such use. It’s like a hybrid of throw-away and non throw-away. You can reset ‘next’ with an announcement for developers, but don’t do it so frequently.

next

tag

Page 56: The gitworkflows(7) illustrated

‘next’ will be branched from ‘master’.(branch next master)

Page 57: The gitworkflows(7) illustrated

Merge the remaining old active topic, C…(checkout next and merge topic-C)

merge

Page 58: The gitworkflows(7) illustrated

And merge new one, say topic D.

merge

Page 59: The gitworkflows(7) illustrated

Here, ‘pu’ always should be branched from the most advanced non-throw-away integration branch.

Page 60: The gitworkflows(7) illustrated

So let’s rebuild ‘pu’ on ‘next’ at this time.(checkout pu and reset --hard next)

reset

Page 61: The gitworkflows(7) illustrated

Old ‘pu’ will be deleted.

Page 62: The gitworkflows(7) illustrated

And then...

Page 63: The gitworkflows(7) illustrated

Merge the remaining new topic, say topic E.

merge

Page 64: The gitworkflows(7) illustrated

Then, push ‘next’ and ‘pu’(push origin next +pu)

Page 65: The gitworkflows(7) illustrated

Note that you and developers involved cannot work on ‘next’ because it sometimes get reset. So all feature branches should be forked off from ‘master’

Page 66: The gitworkflows(7) illustrated

What are the differences between ‘next’ and ‘pu’?

Page 67: The gitworkflows(7) illustrated

‘pu’ is easily disposable but ‘next’ isn’t.

Page 68: The gitworkflows(7) illustrated

For example, if a topic merged only to ‘pu’ have a bug and fixed on it ...

commit

Page 69: The gitworkflows(7) illustrated

Then, simply reset ‘pu’ to ‘next’...(checkout pu and reset --hard next)

reset

Page 70: The gitworkflows(7) illustrated

And merge new tip of that topic.(i.e. rewind and reconstruct ‘pu’)

merge

Page 71: The gitworkflows(7) illustrated

On the other hand, if a topic kept in ‘next’ have another commit...

commit

Page 72: The gitworkflows(7) illustrated

‘next’ can’t be reset, so just merge new tip of that topic on current ‘next’...

Page 73: The gitworkflows(7) illustrated

Like this.

merge

Page 74: The gitworkflows(7) illustrated

And rebuild ‘pu’ on new ‘next’

reset and merge

Page 75: The gitworkflows(7) illustrated

Note that you can merge the new branch head of topic D into ‘pu’ first if needed.(e.g. it has too large impact to merge into ‘next’)

merge into ‘pu’ first(+ push and test)

if it looks good,then merge into ‘next’

reconstruct ‘pu’.this is identical graph

shown in previous page

Page 76: The gitworkflows(7) illustrated

Here is another situation.You got new topic (say F).

Page 77: The gitworkflows(7) illustrated

You found a topic kept in ‘pu’, topic E, was totally broken and the topic developer can’t fix it right away. When it happened, just reconstruct ‘pu’ ignoring broken branches.

Broken

Page 78: The gitworkflows(7) illustrated

Reset ‘pu’....

reset

Page 79: The gitworkflows(7) illustrated

And merge again only good branches.

merge

Page 80: The gitworkflows(7) illustrated

If the broken branch was rebased with fixes after a while...

rebased

rebased topic

Page 81: The gitworkflows(7) illustrated

Merge the rebased new branch into ‘pu’

rebased merge

Page 82: The gitworkflows(7) illustrated

If you find a branch kept in ‘next’, e.g. topic C, is broken and it can’t be fixed for a while...

Broken

Page 83: The gitworkflows(7) illustrated

You should revert the whole branch(revert -m 1 <merge commit>)

revert

revert commit

reverted merge

Page 84: The gitworkflows(7) illustrated

Of course you should rebuild ‘pu’ and push them.

reset and merge

Page 85: The gitworkflows(7) illustrated

After a while, when the topic C was fixed all bugs rebasing it...

rebased

Page 86: The gitworkflows(7) illustrated

Merge it into ‘next’...

merge

Page 87: The gitworkflows(7) illustrated

And rebuild ‘pu’, then push ‘next’ and ‘pu’.

reset and merge

Page 88: The gitworkflows(7) illustrated

Again, note that ‘next’ shouldn’t be reset easily like ‘pu’.When you want to redo something on ‘next’, just revert or re-merge instead.

Page 89: The gitworkflows(7) illustrated

But ‘next’ can be reset with announcements for involved developers when it get awfully dirty with a number of revert and duplicate merges.

Page 90: The gitworkflows(7) illustrated

And you’ll also have chances to reset ‘next’ after feature release. It will be shown later.Let’s keep developing for the second release for now.

Page 91: The gitworkflows(7) illustrated

When you think topics merged into ‘next’ are stable / having good design / etc. you can merge them into ‘master’

Good enough to be merged into ‘master’

Page 92: The gitworkflows(7) illustrated

When you think topics merged into ‘next’ are stable / having good design / etc. you can merge them into ‘master’

Good enough to be merged into ‘master’

Page 93: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

new topic

Page 94: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

merge

Page 95: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

good enoughfor master

Page 96: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

merge

Page 97: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

good enoughfor next

Page 98: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

merge

reset and merge

Page 99: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

new topic

Page 100: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

merge

Page 101: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

good enoughfor next

Page 102: The gitworkflows(7) illustrated

Repeat ‘pu’ -> ‘next’ -> ‘master’ cycle until enough features required for the next feature release are merged into ‘master’

merge

reset and merge

Page 103: The gitworkflows(7) illustrated

These merges in ‘pu’ -> ‘next’ -> ‘master’ order, downstream-ward propagation of features, are called ‘graduate’.

Page 104: The gitworkflows(7) illustrated

Unfortunately sometimes even topics merged into ‘master’ have bugs.Fix them on their topics? No.

a bug found

Page 105: The gitworkflows(7) illustrated

Once a topic merged into ‘master’, it will be regarded as ‘master’ itself. So fix branches should be created on ‘master’ for bugs of ‘master’.

fix-branch for the bug

Page 106: The gitworkflows(7) illustrated

Merge it into (‘pu’ and) ‘next’ first.

merge

reset and merge

Page 107: The gitworkflows(7) illustrated

Then merge it into ‘master’ if it looks good.

merge

Page 108: The gitworkflows(7) illustrated

Note that you can merge the fix branch into ‘master’ directly when the commits in fix branch are trivial.

fix-branch for the bug

Page 109: The gitworkflows(7) illustrated

Note that you can merge the fix branch into ‘master’ directly when the commits in fix branch are trivial.

merge

Page 110: The gitworkflows(7) illustrated

But after that, don’t forget to merge ‘master’ into ‘next’ for the fix will be included in ‘next’(‘next’ must have the bug because it has all topics merged into ‘master’)

merge

reset and merge

Page 111: The gitworkflows(7) illustrated

There is another situation for fixing bugs.If the release v1.0.0 have a bug, how should we address it?

a bug found

Page 112: The gitworkflows(7) illustrated

Fix it on ‘master’ and let v1.0.0 users upgrade to ‘master’?But some v1.0.0 users don’t want to use new features merged into ‘master’.

Page 113: The gitworkflows(7) illustrated

So you want a new integration branch only for bug fixing.‘maint’ is such a branch. It will be branched from the latest feature release, i.e. v1.0.0.

maint

create branch

Page 114: The gitworkflows(7) illustrated

The fix branch have to be branched from ‘maint’.Don’t branch from ‘master’ or any upstream.

fix-branch for the bug

Page 115: The gitworkflows(7) illustrated

If you branch the fix branch for ‘maint’ from ‘master’...

*WRONG*

fix-branch for the bug*WRONG*

Page 116: The gitworkflows(7) illustrated

When the fix branch merged into ‘maint’, additional topics are also merged into ‘maint’. Those downwards merging will break ‘maint’ branch.

*WRONG*

merge*WRONG*

unintentionallymerged commits

Page 117: The gitworkflows(7) illustrated

You can handle this case by cherry-pick the commit into ‘maint’, but you should take care where you fork off from.

cherry-pick

workaround

Page 118: The gitworkflows(7) illustrated

So the fix branch should be forked off from ‘maint’.As a general rule, fork off topics from the oldest integration branch which the topics will be finally merged into.

fix-branch for the bug

Page 119: The gitworkflows(7) illustrated

Basically merge the fix branch for ‘maint’ into ‘next’ (or ‘pu’) first as usual because ‘maint’ never get reset.

merge

reset and merge

Page 120: The gitworkflows(7) illustrated

Then merge it into ‘maint’ when it looks good on ‘next’.

merge

Page 121: The gitworkflows(7) illustrated

But...

Page 122: The gitworkflows(7) illustrated

Of course you can merge fix branches directly into ‘maint’ when they are trivial.

merge

Page 123: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

Page 124: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

merge

Page 125: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

Page 126: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

merge

Page 127: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

merge

Page 128: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

merge

Page 129: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

reset and merge

Page 130: The gitworkflows(7) illustrated

Sometimes you should merge ‘maint’ into ‘master’, and merge ‘master’ into ‘next’ for propagation of the fixes.Periodic upward merges are good habits.

Page 131: The gitworkflows(7) illustrated

When some fixes accumulated in ‘maint’, publish a fix-release.

Page 132: The gitworkflows(7) illustrated

Tag v1.0.1 on ‘maint’ for the fix-release and push it.

v1.

0.1

tag

Page 133: The gitworkflows(7) illustrated

Well, after a while you want to make a new feature-release.And you want have a code-freeze period for this release.

Page 134: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

merge fix branches onlywhile frozen

Page 135: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

fix

feature

Page 136: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

fix

Page 137: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

merging maint is ok

fix

Page 138: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

merging fix branches are also ok

fix

Page 139: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

Don’t merge feature branches

fix

Page 140: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

Don’t merge feature branches

fix

Page 141: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

fix

Page 142: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

fix

even though good enough for master...

Page 143: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

Don’t merge ANY feature branches

fix

Page 144: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

Don’t merge ANY feature branches

fix

Page 145: The gitworkflows(7) illustrated

To freeze your code, just stop merging feature topics and only merge fix-topics, including ‘maint’, into ‘master’.

fix

feature

fix

Page 146: The gitworkflows(7) illustrated

You can merge feature topics into ‘next’ for integration of them while ‘master’ is frozen. So you don’t have to stop developing for the code-freeze.

merging feature branches are OKay

fix

feature

fix

Page 147: The gitworkflows(7) illustrated

You can merge feature topics into ‘next’ for integration of them while ‘master’ is frozen. So you don’t have to stop developing for the code-freeze.

merging fix branchesare also OKay

fix

feature

fix

Page 148: The gitworkflows(7) illustrated

You can merge feature topics into ‘next’ for integration of them while ‘master’ is frozen. So you don’t have to stop developing for the code-freeze.

Page 149: The gitworkflows(7) illustrated

You can merge feature topics into ‘next’ for integration of them while ‘master’ is frozen. So you don’t have to stop developing for the code-freeze.

rebase

rebasing active topics are OKay

Page 150: The gitworkflows(7) illustrated

You can merge feature topics into ‘next’ for integration of them while ‘master’ is frozen. So you don’t have to stop developing for the code-freeze.

rebase

rebasing active topics are OKay

Page 151: The gitworkflows(7) illustrated

You can merge feature topics into ‘next’ for integration of them while ‘master’ is frozen. So you don’t have to stop developing for the code-freeze.

reverting or dropping active branches are also

OKay

revert

Page 152: The gitworkflows(7) illustrated

You can merge feature topics into ‘next’ for integration of them while ‘master’ is frozen. So you don’t have to stop developing for the code-freeze.

reverting or dropping active branches are also

OKay

Page 153: The gitworkflows(7) illustrated

The code-freeze period has done. Now you will make feature-release.

Page 154: The gitworkflows(7) illustrated

Before tagging, make sure ‘maint’ is fully merged into ‘master’ by git merge maint on ‘master’. If not merged, some fixes will be missing from the new release.

Already fully merged into master in this case

Page 155: The gitworkflows(7) illustrated

Now release it. Tag v1.1.0 on ‘master’ for the feature-release and push it.

tag

v1.

1.0

Page 156: The gitworkflows(7) illustrated

New release has done. But you have some tasks for the ‘next’ and ‘maint’ after feature-release

Page 157: The gitworkflows(7) illustrated

Let’s do for ‘next’.At first reset ‘next’ to ‘master’

reset to master

leave a tag for in case messed up

Page 158: The gitworkflows(7) illustrated

Then merge active topics they weren’t included in the last release. (And rebuild ‘pu’ if needed)

merge active branches

Page 159: The gitworkflows(7) illustrated

Then merge active topics they weren’t included in the last release. (And rebuild ‘pu’ if needed)

merge active branches

Page 160: The gitworkflows(7) illustrated

Then merge active topics they weren’t included in the last release. (And rebuild ‘pu’ if needed)

check diff for making sure that

they are equivalentdiff

Page 161: The gitworkflows(7) illustrated

Then merge active topics they weren’t included in the last release. (And rebuild ‘pu’ if needed)

rebuild pu

Page 162: The gitworkflows(7) illustrated

This rewind and reconstruction of ‘next’ is for cleaning up the history of it. Actually you can do this anytime with an announcement. But it is good point to do this right after a feature release.

Page 163: The gitworkflows(7) illustrated

This rewind and reconstruction of ‘next’ is for cleaning up the history of it. Actually you can do this anytime with an announcement. But it is good point to do this right after a feature release.

Page 164: The gitworkflows(7) illustrated

Next, let’s see about ‘maint’The task for ‘maint’ is simple. Just fast-forward ‘maint’ to ‘master’.

Fast-Foward to master

Page 165: The gitworkflows(7) illustrated

This is done by git merge --ff-only master on ‘maint’. If it fail, the last release is missing some fixes because ‘maint’ must have some commits that are not in ‘master’.

Fast-Foward to master

Page 166: The gitworkflows(7) illustrated

If you merge ‘maint’ into ‘master’ before the release like already shown, the fast-forward will succeed.

Page 167: The gitworkflows(7) illustrated

Note that if you want keep maintenance branch for the previous feature-release, you can leave another maint branch, e.g. maint-1.0, for it.

maint-1.0

Page 168: The gitworkflows(7) illustrated

After the feature-release, repeat the same workflows already shown. This is the gitworkflows(7). Keep on developing with it.

New topic and...

Page 169: The gitworkflows(7) illustrated

Conclusion (1/2)● Use throw-away integration branch like pu● Merge topics into the throw-away(TA) first● Test in TAs before merging topics into master● You can use hybrid of TA and non-TA like

next● next can be reset with announcements.● master and maint cannot be reset

Page 170: The gitworkflows(7) illustrated

Conclusion (2/2)● Don’t base your work on pu or next● Fork off topics from the oldest integ-branch

which the topics will be finally merged into● Merge integration branches upwards● Tag master for feature-releases● Tag maint for fix-releases

Page 171: The gitworkflows(7) illustrated

See also● gitworkflows(7)● Documentation/SubmittingPatches

in Git source tree● MaintNote in ‘todo’ branch of git.git● the Git Blame blog by Junio C Hamano

Page 172: The gitworkflows(7) illustrated

Q and A

Page 173: The gitworkflows(7) illustrated

Q: What is the difference between next and pu?

A: It depends.

gitworkflows(7) saids pu, throw-away, is for testing the interaction of topics but according to the recent MaintNotes in the git.git, pu is a sort of reminder for the maintainer. next is said to be for testing/polishing for master in both documents.

IMHO pu is a working space and next is a staging area for master. It looks like working tree and index of Git itself.

Page 174: The gitworkflows(7) illustrated

Q: Do I have to keep {‘pu’, ‘next’, ‘maint’}

A: No, you don’t.

Just create and keep them if you need. But I recommend you to use a throw-away at least. You may keep it in your local repos only (i.e. make sure tests are succeeded and then push master).

I’ve seen a project that have only ‘master’, ‘pu’ and another project that have ‘master’, ‘master-pu’, ‘maint’, ‘maint-pu’.

Page 175: The gitworkflows(7) illustrated

Q: Do I have to keep so many topics?

A: Yes.You have to keep them until they’ve been merged into ‘master’ or ‘maint’

But you can assign someone you trust to maintain a certain subsystem with gitworkflows. Then you can just merge his/her ‘master’ into your ‘master’. (actually you need a throw-away)

This is the reason why gitworkflows is thought to be scalable.

Page 176: The gitworkflows(7) illustrated

Q: Do I have to merge a single branch repeatedly?

A: Yes.

When you become tired of resolving identical conflicts, enable git-rerere(1). The ‘rerere’ stands for Reuse Recorded Resolution. It will help you to resolve conflicts that have been resolved once before.

Page 177: The gitworkflows(7) illustrated

Q: May I use GitHub pull requests with gitworkflows?

A: Yes, of course.

For the git.git, GitHub pull requests are simply ignored but it’s just a policy of the project.

“Merge Workflow” in the online manual gitworkflows(7) will suit for GitHub users.

Page 178: The gitworkflows(7) illustrated

Thank you