• Asanka Herath's avatar
    Add a '--inject-current' option to 'git new-branch' · 53a115e6
    Asanka Herath authored
    This option creates a new branch that sets itself as the upstream for
    the current branch and adopts the current branch's upstream as its own.
    
    What does it do?
    ----------------
    
    Imagine we have the following set of branches (as `git map-branches -vv`
    would show it):
    
      origin/master  00001111  [ ahead 1 ]
        foo          00002222  [ ahead 1 ]
          baz *      00003333  [ ahead 1 ]
    
    'baz' is the current branch. If one were to issue the following command:
    
      $ git new-branch --inject-current bar
    
    ... then the branch layout will now look like this:
    
      origin/master  00001111  [ ahead 1 ]
        foo          00002222  [ ahead 1 ]
          bar *      00002222
            baz      00003333  [ ahead 1 ]
    
    Why would you need this?
    ------------------------
    
    When working on a single change or a sequence of changes organized into
    dependent branches, this option lets you quickly create a new branch
    with the correct upstreams so that you can peel off smaller cleanups and
    potentially unrelated changes out of your main feature branch into
    separate branches. These can then be uploaded as dependent CLs.
    
    R=petermayo@chromium.org,iannucci@chromium.org
    
    Change-Id: Id912f8e5c17e267fc52d74bdfac7bbcf87a50908
    Reviewed-on: https://chromium-review.googlesource.com/987529
    Commit-Queue: Asanka Herath <asanka@chromium.org>
    Reviewed-by: 's avatarRobbie Iannucci <iannucci@chromium.org>
    53a115e6
git_new_branch.py 2.77 KB