Changes between Version 11 and Version 12 of GitCrashCourse


Ignore:
Timestamp:
11/05/12 17:18:26 (6 years ago)
Author:
David Sommerseth
Comment:

Describing when to use git merge and git rebase

Legend:

Unmodified
Added
Removed
Modified
  • GitCrashCourse

    v11 v12  
    308308
    309309If there were no conflicts, a merge commit is done automatically for you.
     310
     311
     312== When to use ''git merge'' and when to use ''git rebase'' ==
     313This 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
     315A 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
     317When 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
     319If 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
     321A 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
     335In 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.