git topics review
Pushes the topic branch named to an upstream branch and attempts to open a pull request.
The first part of this command is equivalent to
$ git push --set-upstream <origin> <topic>
To determine which remote to use as , we look at git config values for
branch.<name>.pushRemote
, remote.pushDefault
, and/or branch.<name>.remote
(see git-config(1)) for various branches. In order:
-
Try to find the push remote for the topic branch. For instance, this would exist if you have some global
remote.pushDefault
or already set an upstream for the topic branch. -
Try to find the push remote for the develop branch. Since the next logical step in the workflow is for the topic branch to be merged to develop for integration, it probably makes sense to push the topic branch to the same remote as develop (if any).
-
Try to find the push remote for the master branch. develop and master would likely be tracked on the same remote (which would typically just be
origin
), but if we can't find any push remote for develop, we may as well try master in case it's any different. -
All else fails, default to
origin
.
With the topic branch pushed upstream, it should now be available to other people with access to the same remote. That way, before merging a topic branch into develop or master, you may ask for feedback from others.
On GitHub, this means using their web interface to open a
pull request that people can then leave comments on. If 's URL appears
to be from GitHub (i.e., it takes the form of one of the standard clone URLs -
https://github.com/*
or [email protected]:*
), then git web--browse
will be
used to open the GitHub pull request form in your browser.
In this scenario, the second part of this command is equivalent to
$ git web--browse https://github.com/<user>/<repo>/compare/<develop>...<topic>?expand=1
Of course, not every repository is hosted on GitHub. In this scenario, the
command uses the builtin git request-pull
to format a pull request message to
stdout. You could then copy this text into, say, an email.
In this scenario, the second part of this command is equivalent to
$ git branch --edit-description <topic>
$ git request-pull <develop> <origin> <topic>
git-topics(1), git-config(1), git-remote(1), git-branch(1), git-web--browse(1), git-request-pull(1)