Skip to content

Commit 7345179

Browse files
ffespaulirish
authored andcommitted
Update support for open.default.remote config (#79)
1 parent d97b7f3 commit 7345179

File tree

2 files changed

+14
-2
lines changed

2 files changed

+14
-2
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,16 @@ If your Gitlab custom hosted is serving `http` you can also specify this:
126126
git config [--global] gitopen.gitlab.protocol http
127127
```
128128
129+
### Default remote
130+
131+
Normally `git open` opens the remote named `origin`. When you fork a project
132+
and add a remote named `upstream` you often want that upstream to be opened
133+
as the default remote. To accomplice this, you can do this:
134+
135+
```sh
136+
git config open.default.remote upstream
137+
```
138+
129139
## Alternative projects
130140
131141
See [hub](https://github.com/github/hub) for complete GitHub opening support.

git-open

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,12 @@ if ! git rev-parse --is-inside-work-tree &>/dev/null; then
4141
exit 1
4242
fi
4343

44-
# choose remote. priority to: provided argument, detected tracked remote, 'origin'
44+
# choose remote. priority to: provided argument, default in config, detected tracked remote, 'origin'
4545
branch_name=$(git name-rev --name-only HEAD 2>/dev/null)
4646
tracked_remote=$(git config "branch.$branch_name.remote")
47-
remote=${1:-$tracked_remote}
47+
default_remote=$(git config open.default.remote)
48+
remote=${1:-$default_remote}
49+
remote=${remote:-$tracked_remote}
4850
remote=${remote:-"origin"}
4951

5052
# @TODO ls-remote will also expand "insteadOf" items `giturl=$(git ls-remote --get-url $remote)``

0 commit comments

Comments
 (0)