Eksempel: omskrivning af historien
Følgende situation opstår af og til i modne projekter. Med udgangspunkt i en
stabil branch (ofte kaldet master
) begynder man at arbejde på en ny feature
branch (opkaldt efter den pågældende feature). Efter noget tid er den nye
funktionalitet færdigudviklet og klar til at blive merget ind i den stabile
branch. En simpel git merge
er ofte alt, hvad der skal til, og hvis
feature-branchen kun har tilføjet funktionalitet og ikke ændret noget ved det
eksisterende, er merge conflicts sjældne.
Det hænder dog, at den nye feature kræver ændringer i kernefunktionaliteten.
Hvis denne funktionalitet udvikles i master
-branchen, er en merge fra
master
ind i feature-branchen nødvendig inden udviklingen kan fortsætte.
Efter den endelige merge tilbage ind i den stabile branch, kan situationen se
sådan her ud. Bemærk, at feature-branchen hedder parallel2
, og den stabile
branch hedder pipelining
.
* 456d75f (HEAD, pipelining) Merge branch 'parallel2' into pipelining |\ | * 34dca68 (origin/parallel2, parallel2) Add ut-pipelining parallel_step | * 004e459 Support step() in parallelized pipelines. | * e7c8378 Add note about item_type in parallel.h | * 9943b9e Strengthen parallel code, such that it does not require the number of items | * ea55f36 Add TODO in parallel | * 2384687 Merge branch 'pipelining' into parallel2 | |\ | * \ 703e434 Merge branch 'pipelining' into parallel2 | |\ \ | * | | d415186 Change parallel and parallel_ordered test parameters | * | | 9372b9c Add progress indicator to parallel test and change default modulus | * | | 2a1b9d4 More work on parallelism framework. | * | | a7b100c Fix ut-pipelining sequence generator/verifier | * | | e2b8a43 Add class-level documentation to parallel pipelining stuff | * | | 2055d48 Implement parallel pipelining processing as a library functionality * | | | ebc963d (origin/pipelining) Gather pipelining documentation into a single document * | | | b0e0830 Simplify Graham scan code by using less templates * | | | 39c109c Use class keyword in pipelining when appropriate. * | | | 3f59291 fixup! Replace old convex hull app with new pipelining convex hull app * | | | c756184 Replace old convex hull app with new pipelining convex hull app | |_|/ |/| | * | | 4422a60 Add iterators tests to CMakeLists * | | f652286 Call pipe_segment::end() in actor order. * | | 4b3f9c0 Use push_input_iterator in pipelining2 * | | 016bf6f Add typed_push_output_iterators, for output iterators like ostream_iterator that define value_type to be void (why?) | |/ |/| * | e888bc2 Make sorter forward number of items in output * | 6c60ab5 Fix memory overusage in pipelining * | 2fdaf91 Fix merge sorter crash when evacuating in internal reporting mode with no elements to sort * | 007776f Add ut-pipelining sorttrivial test to test sorting sequences of length 0, 1 and 2 |/ * dad266a Fix struct/class warning
Det har undervejs i udviklingen været nødvendigt med to merges fra stable til feature. Det ser dog ikke så pænt ud i historikken.
Vores mål er at erstatte de to undervejs merges med en enkelt merge med
origin/pipelining
.
Det gøres således:
$ git checkout parallel2 Switched to branch 'parallel2' $ git reset --hard 2384687 HEAD is now at 2384687 Merge branch 'pipelining' into parallel2 $ git merge ebc963d ... merge output ... $ git tag new-merge $ git reset --hard d415186 HEAD is now at d415186 Change parallel and parallel_ordered test parameters $ git checkout new-merge -- . $ echo ebc963d > .git/MERGE_HEAD $ git commit -m "Merge branch 'pipelining' into parallel2" [parallel2 92ca529] Merge branch 'pipelining' into parallel2 $ git tag forged-merge $ git reset --hard 34dca68 HEAD is now at 34dca68 Add ut-pipelining parallel_step $ git rebase 2384687 --onto forged-merge First, rewinding head to replay your work on top of it... Applying: Add TODO in parallel Applying: Strengthen parallel code, such that it does not require the number of items Applying: Add note about item_type in parallel.h Applying: Support step() in parallelized pipelines. Applying: Add ut-pipelining parallel_step $ git checkout pipelining Switched to branch 'pipelining' $ git merge --no-ff parallel2 Merge made by the 'recursive' strategy. ... merge output ...
Resultatet er følgende historik:
* 228a6bb (HEAD, pipelining) Merge branch 'parallel2' into pipelining |\ | * 9ba61db (parallel2) Add ut-pipelining parallel_step | * 12925e5 Support step() in parallelized pipelines. | * 6b1a139 Add note about item_type in parallel.h | * 6579195 Strengthen parallel code, such that it does not require the number of items | * d428d5b Add TODO in parallel | * c827808 (tag: forged-merge) Merge branch 'pipelining' into parallel2 | |\ | |/ |/| * | ebc963d (origin/pipelining) Gather pipelining documentation into a single document * | b0e0830 Simplify Graham scan code by using less templates * | 39c109c Use class keyword in pipelining when appropriate. * | 3f59291 fixup! Replace old convex hull app with new pipelining convex hull app * | c756184 Replace old convex hull app with new pipelining convex hull app * | 4422a60 Add iterators tests to CMakeLists * | f652286 Call pipe_segment::end() in actor order. * | 4b3f9c0 Use push_input_iterator in pipelining2 * | 016bf6f Add typed_push_output_iterators, for output iterators like ostream_iterator that define value_type to be void (why?) * | e888bc2 Make sorter forward number of items in output * | 6c60ab5 Fix memory overusage in pipelining * | 2fdaf91 Fix merge sorter crash when evacuating in internal reporting mode with no elements to sort * | 007776f Add ut-pipelining sorttrivial test to test sorting sequences of length 0, 1 and 2 | * d415186 Change parallel and parallel_ordered test parameters | * 9372b9c Add progress indicator to parallel test and change default modulus | * 2a1b9d4 More work on parallelism framework. | * a7b100c Fix ut-pipelining sequence generator/verifier | * e2b8a43 Add class-level documentation to parallel pipelining stuff | * 2055d48 Implement parallel pipelining processing as a library functionality |/ * dad266a Fix struct/class warning