|
| 1 | +# git-open - Open the repository's website in your browser. |
| 2 | + |
| 3 | + |
| 4 | +## SYNOPSIS |
| 5 | + |
| 6 | +`git-open` [remote-name] [branch-name] |
| 7 | + |
| 8 | +`git-open` --issue |
| 9 | + |
| 10 | + |
| 11 | +## DESCRIPTION |
| 12 | + |
| 13 | +`git-open` opens the repository's website in your browser. The major well known |
| 14 | +git hosting services are supported. |
| 15 | + |
| 16 | + |
| 17 | +## OPTIONS |
| 18 | + |
| 19 | + |
| 20 | +`-i`, `--issue` |
| 21 | + Open the current issue. When the name of the current branch matches the right pattern, |
| 22 | + it will open the webpage with that issue. See `EXAMPLES` for more information. |
| 23 | + This only works on GitHub, GitLab, Visual Studio Team Services and Team Foundation Server at the moment. |
| 24 | + |
| 25 | +`-h` |
| 26 | + Show a short help text. |
| 27 | + |
| 28 | + |
| 29 | +## EXAMPLES |
| 30 | + |
| 31 | +```sh |
| 32 | +$ git open |
| 33 | +``` |
| 34 | + |
| 35 | +It opens https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/ |
| 36 | + |
| 37 | +```sh |
| 38 | +$ git open someremote |
| 39 | +``` |
| 40 | + |
| 41 | +It opens https://github.com/PROVIDED_REMOTE_USER/CURRENT_REPO/ |
| 42 | + |
| 43 | +```sh |
| 44 | +$ git open someremote somebranch |
| 45 | +``` |
| 46 | + |
| 47 | +It opens https://github.com/PROVIDED_REMOTE_USER/CURRENT_REPO/tree/PROVIDED_BRANCH |
| 48 | + |
| 49 | +```sh |
| 50 | +$ git open --issue |
| 51 | +``` |
| 52 | + |
| 53 | +If branches use naming convention of `issues/#123`, it opens |
| 54 | +https://github.com/TRACKED_REMOTE_USER/CURRENT_REPO/issues/123 |
| 55 | + |
| 56 | + |
| 57 | +## SUPPORTED REMOTE REPOSITORIES |
| 58 | + |
| 59 | +git-open can automatically guess the corresponding repository page for remotes |
| 60 | +(default looks for `origin`) on the following hosts: |
| 61 | + |
| 62 | +- github.com |
| 63 | +- gist.github.com |
| 64 | +- gitlab.com |
| 65 | +- GitLab CE/EE (self hosted GitLab, see `CONFIGURATION`) |
| 66 | +- bitbucket.org |
| 67 | +- Atlassian Bitbucket Server (formerly _Atlassian Stash_) |
| 68 | +- Visual Studio Team Services |
| 69 | +- Team Foundation Server (on-premises) |
| 70 | + |
| 71 | + |
| 72 | +## CONFIGURATION |
| 73 | + |
| 74 | +To configure git-open you may need to set some `git config` options. |
| 75 | +You can use `--global` to set across all repos, instead of just the local one. |
| 76 | + |
| 77 | +```sh |
| 78 | +$ git config [--global] option value |
| 79 | +``` |
| 80 | + |
| 81 | +### Configuring which remote to open |
| 82 | + |
| 83 | +By default, `git open` opens the remote named `origin`. However, if your current branch is remotely-tracking a different remote, that tracked remote will be used. |
| 84 | + |
| 85 | +In some instances, you may want to override this behavior. When you fork a project |
| 86 | +and add a remote named `upstream` you often want that upstream to be opened |
| 87 | +rather than your fork. To accomplish this, you can set the `open.default.remote` within your project: |
| 88 | + |
| 89 | +```sh |
| 90 | +git config open.default.remote upstream |
| 91 | +``` |
| 92 | + |
| 93 | +This is equivalent to always typing `git open upstream`. |
| 94 | + |
| 95 | + |
| 96 | +### GitLab options |
| 97 | + |
| 98 | +To configure GitLab support (or other unique hosting situations) you may need to set some options. |
| 99 | + |
| 100 | +`open.[gitdomain].domain` |
| 101 | + The (web) domain to open based on the provided git repo domain. |
| 102 | + |
| 103 | +`open.[gitdomain].protocol` |
| 104 | + The (web) protocol to open based on the provided git repo domain. Defaults to `https`. |
| 105 | + |
| 106 | +```sh |
| 107 | +git config [--global] open.[gitdomain].domain [value] |
| 108 | +git config [--global] open.[gitdomain].protocol [value] |
| 109 | +``` |
| 110 | + |
| 111 | +**Example** |
| 112 | +- Your git remote is at `ssh://[email protected]:7000/XXX/YYY.git` |
| 113 | +- Your hosted gitlab is `http://repo.intranet/subpath/XXX/YYY` |
| 114 | + |
| 115 | +```sh |
| 116 | +git config [--global] "open.https://git.internal.biz.domain" "repo.intranet/subpath" |
| 117 | +git config [--global] "open.https://git.internal.biz.protocol" "http" |
| 118 | +``` |
| 119 | + |
| 120 | + |
| 121 | +## DEBUGGING |
| 122 | + |
| 123 | +You can run `git-open` in `echo` mode, which doesn't open your browser, but just prints the URL to stdout: |
| 124 | + |
| 125 | +```sh |
| 126 | +env BROWSER='echo' ./git-open |
| 127 | +``` |
| 128 | + |
| 129 | + |
| 130 | +## AUTHORS |
| 131 | + |
| 132 | +Jason McCreary did the initial hard work. Paul Irish based his project on his work. |
| 133 | +Since then many contributors have submitted great PRs. |
| 134 | + |
| 135 | + |
| 136 | +## SEE ALSO |
| 137 | + |
| 138 | +git(1), git-remote(1), git-config(1), [Project page](https://github.com/paulirish/git-open) |
0 commit comments