Differences
This shows you the differences between two versions of the page.
| Both sides previous revision Previous revision Next revision | Previous revision | ||
| gitworkflow:triangularworkflow [2015/09/14 15:41] – JulienCharbon | gitworkflow:triangularworkflow [2015/09/14 20:34] (current) – JulienCharbon | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| ====== Git Triangular Workflow ====== | ====== Git Triangular Workflow ====== | ||
| - | This git workflow | + | The main characteristics of this workflow |
| - | * Keeping in sync a %%FreeBSD%% release branch, e.g. releng/ | + | * Develop changes on top of %%FreeBSD%% release branch, e.g. '' |
| - | * Develop improvements/ | + | * Publish these changes |
| - | * Once these changes have been tested and matured enough, | + | * Once these changes have been tested and have matured enough, up-port them on top of HEAD for review |
| * Once review accepted, push them in HEAD | * Once review accepted, push them in HEAD | ||
| - | * Rebase not yet accepted/too recent changes from releng/X.Y to releng/ | + | * Rebase |
| - | ====== Introduction ====== | + | For experimented git users (i.e. users that already fell in every git pitfalls) this workflow is common sense, but might help some to start %%FreeBSD%% contributions with a straightforward workflow. |
| - | This workflow assumes you use multiple repositories, | + | {{gitworkflow/ |
| + | |||
| + | ====== Introduction ====== | ||
| - | origin repository:: | + | This workflow assumes you use multiple repositories, i.e.: |
| - | upstream | + | * **origin |
| - | * **Main Rules** | + | * **upstream repository**: The official |
| - | * Changes coming from '' | + | |
| - | * Changes made in '' | + | |
| - | ===== Local Git Repository Configuration ===== | + | * **Main workflow rules being** |
| + | * Changes coming from '' | ||
| + | * Changes developed in '' | ||
| - | * **Note**: These steps are done only once for a given local git repository | + | ====== Local Git Repository First Steps ====== |
| - | Clone personal %%FreeBSD%% git repository | + | Clone personal %%FreeBSD%% git repository |
| < | < | ||
| Line 39: | Line 41: | ||
| </ | </ | ||
| - | * **Note**: '' | + | * **Note**: '' |
| - | ===== Origin Repository | + | ====== Origin Repository |
| + | |||
| + | Origin repository branches will look like: | ||
| < | < | ||
| Line 49: | Line 53: | ||
| 10.1-next/ | 10.1-next/ | ||
| 10.2-next/ | 10.2-next/ | ||
| + | master | ||
| </ | </ | ||
| - | The '' | + | The '' |
| - | ===== Create | + | ====== Create |
| Get last upstream changes | Get last upstream changes | ||
| Line 73: | Line 78: | ||
| </ | </ | ||
| - | ==== Checkout a X.Y-next Branch ==== | + | ===== Checkout a X.Y-next Branch |
| - | If the '' | + | If the '' |
| < | < | ||
| $ git fetch origin | $ git fetch origin | ||
| - | $ git checkout -t origin/10.0-next | + | $ git checkout -t origin/10.2-next |
| </ | </ | ||
| - | * **Note**: Need to do this step only once per '' | + | ====== Create master Branch and Publish it ====== |
| - | ==== Merge Errata/ | + | Get last upstream changes |
| - | * **Note**: No Operating System is without sins, thus you need to merge Errata/Security patches from corresponding releng branch | + | < |
| + | $ git fetch upstream | ||
| + | </code> | ||
| - | Checkout | + | Create new '' |
| + | |||
| + | < | ||
| + | $ git checkout -t upstream/ | ||
| + | </ | ||
| + | |||
| + | Publish '' | ||
| + | |||
| + | < | ||
| + | $ git push origin HEAD | ||
| + | </ | ||
| + | |||
| + | ====== Make and Publish Custom Changes in Origin Repository ====== | ||
| + | |||
| + | Checkout | ||
| + | |||
| + | < | ||
| + | $ git checkout 10.2-next | ||
| + | $ git pull --rebase | ||
| + | </ | ||
| + | |||
| + | Make changes and locally commit them | ||
| + | |||
| + | < | ||
| + | $ vim foo/bar.c | ||
| + | # Hack, test, hack | ||
| + | $ git add foo/bar.c | ||
| + | $ git commit -m " | ||
| + | </ | ||
| + | |||
| + | Once tested, rebase on top of last origin repository changes, and publish | ||
| + | |||
| + | < | ||
| + | $ git pull --rebase | ||
| + | $ git push origin HEAD | ||
| + | </ | ||
| + | |||
| + | ====== Merge Errata/ | ||
| + | |||
| + | * **Note**: No Operating System is without sins, thus you need to merge Errata/ | ||
| + | |||
| + | Checkout '' | ||
| < | < | ||
| Line 95: | Line 143: | ||
| </ | </ | ||
| - | Get last upstream changes and check the log | + | Get last upstream changes and check the log for Errata/ |
| < | < | ||
| Line 102: | Line 150: | ||
| </ | </ | ||
| - | Merge last changes from upstream | + | Merge last upstream |
| < | < | ||
| - | $ git merge upstream/ | + | $ git merge upstream/ |
| </ | </ | ||
| - | Resolve conflicts if any, than check final result | + | Resolve conflicts if any, than check the result |
| < | < | ||
| Line 114: | Line 162: | ||
| </ | </ | ||
| - | Publish merged upstream changes in orign | + | Publish merged upstream changes in origin |
| < | < | ||
| Line 120: | Line 168: | ||
| </ | </ | ||
| - | Next you can update %%FreeBSD%% release number in '' | + | Next you can update %%FreeBSD%% release number in '' |
| - | ==== Create | + | ===== Create Tag and Publish it ===== |
| < | < | ||
| Line 129: | Line 177: | ||
| </ | </ | ||
| - | %%=%%= Checkout a Private | + | ===== Checkout a Tag ===== |
| < | < | ||
| Line 135: | Line 183: | ||
| </ | </ | ||
| - | ==== Make and Publish | + | ====== Rebase |
| - | Checkout local work branch | + | Get all origin |
| < | < | ||
| + | $ git fetch upstream | ||
| + | $ git fetch origin | ||
| + | $ git checkout 10.1-next | ||
| + | $ git pull --rebase | ||
| $ git checkout 10.2-next | $ git checkout 10.2-next | ||
| $ git pull --rebase | $ git pull --rebase | ||
| </ | </ | ||
| - | Make source code changes | + | Start an interactive rebase for all changes |
| < | < | ||
| - | $ vim foo/bar.c | + | $ git rebase -i --onto 10.2-next upstream/release/10.1.0 10.1-next |
| - | # Hack, test, hack | + | |
| - | $ git add foo/bar.c | + | |
| - | $ git commit | + | |
| </ | </ | ||
| - | Get last remote | + | * **Note**: See [[/ |
| + | |||
| + | * **Note**: Rebase is smart/dumb enough to skip all already accepted included the new '' | ||
| + | |||
| + | * **Note**: Rebase will skip all Errata/ | ||
| + | |||
| + | During the interactive rebase you have in opportunity to: | ||
| + | |||
| + | * Remove now irrelevant changes | ||
| + | * Squash changes related to same fix/feature implementation in only one commit: | ||
| + | * Make things easier for future rebases | ||
| + | * Make history easier to read | ||
| + | * Cleaner patch for upstream proposal | ||
| + | * Re-order your changes | ||
| + | |||
| + | This is different workflow than the classical SVN vendor model merge workflow, here we want to see our changes always on top of the last release branch: | ||
| + | * Custom | ||
| + | * Custom changes will be on top the last release version, | ||
| + | |||
| + | ====== Advantages/ | ||
| + | |||
| + | ===== Advantages ===== | ||
| + | |||
| + | * Use of last release branch for stability | ||
| + | * Custom changes/ | ||
| + | * No need to wait upstream acceptation before enjoying fixes and improvements | ||
| + | * These changes make great candidates for MFC (Merge From Current) once accepted in CURRENT | ||
| + | * Keep patches clean over new release branches | ||
| + | * The origin repository includes only the branches you are working on/you care about. | ||
| + | * Interface nicely with %%FreeBSD%% reviews (Phabricator/ | ||
| + | |||
| + | ===== Disadvantages ===== | ||
| + | |||
| + | * Development is not done in CURRENT | ||
| + | * Patches are “up-ported” to CURRENT once tested/have matured enough | ||
| + | * Patches are in two branches until accepted: | ||
| + | * '' | ||
| + | * '' | ||
| + | |||
| + | ====== More Usages Examples ====== | ||
| + | |||
| + | ===== Creating a Review for CURRENT from X.Y-next branch ===== | ||
| + | |||
| + | Checkout last changes from '' | ||
| < | < | ||
| + | $ git fetch upstream | ||
| + | $ git checkout master | ||
| $ git pull --rebase | $ git pull --rebase | ||
| - | $ git push origin HEAD | ||
| </ | </ | ||
| - | ==== Rebase Custom Changes onto a New Release Branch ==== | + | Create review branch |
| - | Get personal repository | + | < |
| + | $ git checkout -b feature-foo-review master | ||
| + | $ git push -u origin HEAD # It creates the base commit for the review | ||
| + | </ | ||
| + | |||
| + | Cherry-pick | ||
| < | < | ||
| - | $ git fetch upstream | + | $ git log origin/ |
| - | $ git fetch origin | + | $ git cherry-pick $SHA1 $SHA2 |
| - | $ git checkout 10.1-next | + | </ |
| - | $ git pull --rebase | + | |
| - | $ git checkout | + | and create the review |
| + | |||
| + | < | ||
| + | $ arc which # Check that commit $SHA1 and $SHA2 will be part of the review | ||
| + | $ arc diff --create # Create review D1234 | ||
| + | </ | ||
| + | |||
| + | ==== Update your Review ==== | ||
| + | |||
| + | If during review changes are required, local commit the desired changes and include them in the review | ||
| + | |||
| + | < | ||
| + | $ vim foo/bar.c | ||
| + | # Hack, test, hack | ||
| + | $ git add foo/bar.c | ||
| + | $ git commit | ||
| + | $ arc which # Check that all desired commits are part of the review | ||
| + | $ arc diff --update D1234 | ||
| + | </ | ||
| + | |||
| + | ==== Rebase your Review on more Recent CURRENT ==== | ||
| + | |||
| + | If the review takes a while, you can rebase | ||
| + | |||
| + | First get last upstream changes | ||
| + | |||
| + | < | ||
| + | $ git checkout | ||
| $ git pull --rebase | $ git pull --rebase | ||
| </ | </ | ||
| - | Start interactive | + | Then rebase |
| < | < | ||
| - | $ git rebase | + | $ git checkout feature-foo-review |
| + | $ git rebase master | ||
| </ | </ | ||
| - | * **Note**: [[/ | + | And update the review |
| - | During | + | < |
| - | * Remove already accepted in upstream | + | $ git push origin master: |
| - | * Remove now irrelevant changes | + | $ arc which # Check that the review includes all desired commit |
| - | * Squash (flatten) changes related to same fix/feature implementation in only one commit: | + | $ arc diff --update D1234 |
| - | * Make things easier for future rebases | + | </code> |
| - | * Make history easier to read | + | |
| - | * Cleaner patch to propose uptream | + | |
| - | This is different | + | ===== Cherry-pick Specific Commits |
| - | * Custom changes will appear atomic | + | |
| - | * Custom changes will be on top the last release version: Easier to propose them to upstream, and for future rebases | + | |
| - | ===== Fetch and cherry pick specific commits | + | Note: Sometimes You might want to get a change |
| - | Checkout | + | Checkout |
| < | < | ||
| Line 202: | Line 324: | ||
| </ | </ | ||
| - | Get last upstream changes and check the log for the SHA of the commit(s) to cherry-pick | + | Get last upstream changes and check the log for the SHA of the desired |
| < | < | ||
| Line 209: | Line 331: | ||
| </ | </ | ||
| - | * **Note**: One may select any branch from which to cherry pick specific commits. | + | Cherry-pick |
| - | + | ||
| - | Cherry-pick changes from '' | + | |
| < | < | ||
| - | $ git cherry-pick | + | $ git cherry-pick SHA |
| </ | </ | ||
| - | * **Note**: Where $SHA is the SHA string of the commit to cherry-pick | + | * **Note**: Where SHA is the SHA string of the commit to cherry-pick |
| - | Resolve conflicts and check commit merge diff | + | Resolve conflicts and check result |
| + | < | ||
| $ git log -p | $ git log -p | ||
| + | </ | ||
| - | Publish cherry-picked | + | Publish cherry-picked changes to origin repository |
| + | < | ||
| $ git pull --rebase | $ git pull --rebase | ||
| $ git push origin HEAD | $ git push origin HEAD | ||
| + | </ | ||