| 310 | |
| 311 | |
| 312 | == When to use ''git merge'' and when to use ''git rebase'' == |
| 313 | This can be a bit difficult to understand at first. But it is important that you learn to separate between what is your ''upstream source'' and what is your ''downstream source''. |
| 314 | |
| 315 | A very rouge description can be that ''upstream source'' is where you will send your changes to in the end. ''Downstream'' are those git repositories which uses 'your' git repository as their ''upstream source''. |
| 316 | |
| 317 | When sending patches to the openvpn-devel mailing list, it is important that your changes are rebased against the latest upstream branch you want to provide your patches against. So to use ''git format-patch'' and/or ''git send-email'' - to send patches to your upstream source, you need to first 'rebase' against the latest git tree you want your changes to be applied to. When this is done, you can use ''git format-patch'' and/or ''git send-email''. |
| 318 | |
| 319 | If you are pulling in changes from other branches who uses 'your branch(es)' as an upstream source, then you need to 'merge' those changes into your own tree. This is because these git repositories are your ''downstream''. This way you can easily further submit these changes to your upstream tree. |
| 320 | |
| 321 | A little ASCII art again: |
| 322 | |
| 323 | {{{ |
| 324 | [official openvpn.git] (Downstream: Bobs repository) |
| 325 | | |
| 326 | | |
| 327 | [Bob Boss's openvpn-bob.git repo] (Upstream: official openvpn.git) |
| 328 | / \ (Downstream: Johns and Janes repos) |
| 329 | / \ |
| 330 | / \ |
| 331 | / \ |
| 332 | [John Doe] [Jane Doe] (Upstream: Bob's repo) |
| 333 | }}} |
| 334 | |
| 335 | In this scenario, Johns and Janes upstream tree is Bob's openvpn-bob.git repository. This means that Bob has two downstream trees, Johns and Janes repositories. Bobs upstream tree is the official openvpn.git repository. So John and Jane should rebase their trees against Bobs repository. When Bob pulls in Johns or Janes changes, he needs to merge them into his tree. Then Bob can rebase his tree against the official upstream openvpn.git repository. When Bob has done that successfully, he can easily submit those changes to the openvpn-devel mailing list. |