Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| gitworkflow:triangularworkflow [2015/09/14 15:31] – 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 |
| + | |||
| + | 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. | ||
| + | |||
| + | {{gitworkflow/ | ||
| ====== Introduction ====== | ====== Introduction ====== | ||
| - | This workflow assumes you use multiple repositories, | + | This workflow assumes you use multiple repositories, |
| - | origin repository:: Our own personal repository with full access, e.g. '' | + | * **origin repository**: Our own personal/ |
| - | upstream repository:: The official %%FreeBSD%% repository with read-only access, e.g. '' | + | * **upstream repository**: The official %%FreeBSD%% repository with read-only access, e.g. '' |
| - | ===== Local Git Repository Configuration ===== | + | * **Main workflow rules being** |
| + | * Changes coming from '' | ||
| + | * Changes developed in '' | ||
| - | * **Note**: These steps need to be done only once for a same local git repository | + | ====== Local Git Repository First Steps ====== |
| - | Clone personal %%FreeBSD%% git repository | + | Clone personal %%FreeBSD%% git repository |
| + | < | ||
| $ git clone git@github.com: | $ git clone git@github.com: | ||
| $ cd freebsd/ | $ cd freebsd/ | ||
| + | </ | ||
| - | Add %%FreeBSD%% upstream as remote and fetch changes | + | Add %%FreeBSD%% upstream as remote |
| + | < | ||
| $ git remote add upstream git@github.com: | $ git remote add upstream git@github.com: | ||
| $ git fetch upstream | $ git fetch upstream | ||
| + | </ | ||
| + | |||
| + | * **Note**: '' | ||
| - | * **Note**: '' | + | ====== Origin Repository Branches ====== |
| - | ===== Repository Hierarchy ===== | + | Origin repository branches will look like: |
| < | < | ||
| Line 41: | Line 53: | ||
| 10.1-next/ | 10.1-next/ | ||
| 10.2-next/ | 10.2-next/ | ||
| + | master | ||
| </ | </ | ||
| - | The '' | + | The '' |
| - | ===== Workflows | + | ====== |
| - | + | ||
| - | ==== Create Release Branch | + | |
| Get last upstream changes | Get last upstream changes | ||
| Line 55: | Line 66: | ||
| </ | </ | ||
| - | Create new '' | + | Create new '' |
| < | < | ||
| Line 61: | Line 72: | ||
| </ | </ | ||
| - | Publish branch to personal | + | Publish branch to origin |
| < | < | ||
| Line 67: | 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**: Security patches are pushed first in corresponding releng branch | + | < |
| + | $ git fetch upstream | ||
| + | </ | ||
| - | Checkout local work branch | + | Create new '' |
| < | < | ||
| - | $ git checkout 10.1-next | + | $ 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 | $ git pull --rebase | ||
| </ | </ | ||
| - | Get last upstream changes and check the log | + | 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 '' | ||
| + | |||
| + | < | ||
| + | $ git checkout 10.2-next | ||
| + | $ git pull --rebase | ||
| + | </ | ||
| + | |||
| + | Get last upstream changes and check the log for Errata/ | ||
| < | < | ||
| Line 96: | Line 150: | ||
| </ | </ | ||
| - | Merge last changes from upstream | + | Merge last upstream |
| < | < | ||
| - | $ git merge upstream/ | + | $ git merge upstream/ |
| </ | </ | ||
| - | Resolve conflicts if any and check final result | + | Resolve conflicts if any, than check the result |
| < | < | ||
| Line 108: | Line 162: | ||
| </ | </ | ||
| - | Publish merged upstream changes | + | Publish merged upstream changes |
| < | < | ||
| Line 114: | Line 168: | ||
| </ | </ | ||
| - | Next you can update %%FreeBSD%% release number in '' | + | Next you can update %%FreeBSD%% release number in '' |
| - | ==== Create | + | ===== Create Tag and Publish it ===== |
| - | $ git tag -a v10.2.4.0 -m "Personal %%FreeBSD%% Release 10.2.4.0" | + | < |
| + | $ git tag -a v10.2.4.0 -m "My FreeBSD Release 10.2.4.0" | ||
| $ git push --tags | $ git push --tags | ||
| + | </ | ||
| - | %%=%%= Checkout a Personal Private | + | ===== Checkout a Tag ===== |
| - | $ git clone git@github.vrsn.com: | + | < |
| - | $ cd freebsd-vrsn/ | + | |
| $ git checkout -t tags/ | $ git checkout -t tags/ | ||
| + | </ | ||
| - | ==== Fetch and cherry pick specific commits from ' | + | ====== Rebase Custom Changes onto a New Release Branch ====== |
| - | 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 | ||
| </ | </ | ||
| - | Get last upstream changes and check the log for the SHA of the commit(s) to cherry-pick | + | Start an interactive rebase |
| < | < | ||
| - | $ git fetch upstream | + | $ git rebase -i --onto 10.2-next |
| - | $ git log upstream/master | + | |
| </ | </ | ||
| - | * **Note**: | + | * **Note**: |
| - | Cherry-pick changes from '' | + | * **Note**: Rebase is smart/dumb enough to skip all already accepted included the new '' |
| - | < | + | * **Note**: Rebase will skip all Errata/Security merge commits, this is the default behaviour and that you actually want as all Errata/ |
| - | $ git cherry-pick $SHA | + | |
| - | </code> | + | |
| - | * **Note**: Where $SHA is the SHA string of the commit | + | During |
| - | Resolve conflicts and check commit | + | * 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 | ||
| - | $ git log -p | + | 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 changes will appear clearly | ||
| + | * Custom changes will be on top the last release version, and be easier to propose them to upstream | ||
| - | Publish cherry-picked upstream changes to Verisign sources | + | ====== Advantages/ |
| - | $ git pull --rebase | + | ===== Advantages ===== |
| - | $ git push origin HEAD | + | |
| + | * 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 ====== | ||
| - | ==== Make and Publish Custom Changes | + | ===== Creating a Review for CURRENT from X.Y-next branch ===== |
| - | Checkout | + | Checkout last changes |
| < | < | ||
| - | $ git checkout | + | $ git fetch upstream |
| + | $ git checkout | ||
| $ git pull --rebase | $ git pull --rebase | ||
| </ | </ | ||
| - | Make source | + | Create review branch |
| + | |||
| + | <code> | ||
| + | $ git checkout -b feature-foo-review master | ||
| + | $ git push -u origin HEAD # It creates the base commit for the review | ||
| + | </ | ||
| + | |||
| + | Cherry-pick | ||
| + | |||
| + | < | ||
| + | $ git log origin/ | ||
| + | $ git cherry-pick $SHA1 $SHA2 | ||
| + | </ | ||
| + | |||
| + | and create the review | ||
| + | |||
| + | < | ||
| + | $ arc which # Check that commit | ||
| + | $ arc diff --create # Create review D1234 | ||
| + | </ | ||
| + | |||
| + | ==== Update your Review ==== | ||
| + | |||
| + | If during review changes are required, local commit the desired changes and include | ||
| < | < | ||
| Line 177: | Line 282: | ||
| # Hack, test, hack | # Hack, test, hack | ||
| $ git add foo/bar.c | $ git add foo/bar.c | ||
| - | $ git commit -m "[bz#42]: Fix this issue" | + | $ git commit -m "Address comments from review D1234" |
| + | $ arc which # Check that all desired commits are part of the review | ||
| + | $ arc diff --update D1234 | ||
| </ | </ | ||
| - | Get last remote | + | ==== Rebase your Review on more Recent CURRENT ==== |
| + | |||
| + | If the review takes a while, you can rebase your changes | ||
| + | |||
| + | First get last upstream changes | ||
| < | < | ||
| + | $ git checkout master | ||
| $ git pull --rebase | $ git pull --rebase | ||
| - | $ git push origin HEAD | ||
| </ | </ | ||
| - | ==== Rebase Custom Changes onto a New Release Branch ==== | + | Then rebase your changes on it |
| - | Get personal repository changes. | + | < |
| + | $ git checkout feature-foo-review | ||
| + | $ git rebase | ||
| + | </ | ||
| + | |||
| + | And update the review | ||
| + | |||
| + | < | ||
| + | $ git push origin master: | ||
| + | $ arc which # Check that the review includes all desired commit | ||
| + | $ arc diff --update D1234 | ||
| + | </ | ||
| + | |||
| + | ===== Cherry-pick Specific Commits from Upstream ===== | ||
| + | |||
| + | Note: Sometimes You might want to get a change from '' | ||
| + | |||
| + | Checkout '' | ||
| < | < | ||
| - | $ 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 | ||
| </ | </ | ||
| - | Start interactive rebase | + | Get last upstream |
| < | < | ||
| - | $ git rebase -i --onto 10.1-next | + | $ git fetch upstream |
| + | $ git log upstream/master | ||
| </ | </ | ||
| - | * **Note**: [[/Interactive rebase|https:// | + | Cherry-pick desired changes from '' |
| - | During the interactive rebase you have in opportunity to: | + | < |
| - | * Remove already accepted in upstream changes | + | $ git cherry-pick SHA |
| - | * Remove now irrelevant changes | + | </code> |
| - | * Squash (flatten) changes related to same fix/feature implementation in only one commit: | + | |
| - | * Make things easier for future rebases | + | |
| - | * Make history easier to read | + | |
| - | * Cleaner patch to propose uptream | + | |
| - | This is different from classical SVN vendor model merge workflow, here we want our changes always on top of the last release: | + | * **Note**: Where SHA is the SHA string |
| - | * Custom changes will appear atomic | + | |
| - | * Custom | + | Resolve conflicts and check result |
| + | |||
| + | < | ||
| + | $ git log -p | ||
| + | </ | ||
| + | |||
| + | Publish cherry-picked | ||
| + | |||
| + | < | ||
| + | $ git pull --rebase | ||
| + | $ git push origin HEAD | ||
| + | </ | ||