Skip to content

Commit ddb75f0

Browse files
Merge pull request #113 from Samxamnom/publish-unpublish
Remote argument for publish and unpublish
2 parents 6ccbd9c + 8e02627 commit ddb75f0

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

doc/examples/index.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ Publishing:
135135
Git alias:
136136

137137
```git
138-
publish = "!git push -u origin $(git current-branch)"
138+
publish = "!f() { git push -u ${1:-origin} $(git current-branch); }; f"
139139
140-
unpublish = "!git push origin :$(git current-branch)"
140+
unpublish = "!f() { git push ${1:-origin} :$(git current-branch); }; f"
141141
```
142142

143143
Branching:

doc/git-publish/index.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,20 @@
55
Git alias:
66

77
```git
8-
publish = !"git push --set-upstream origin $(git current-branch)"
8+
publish = "!f() { git push --set-upstream ${1:-origin} $(git current-branch); }; f"
99
```
1010

11-
Publish the current branch by pushing upstream to origin,
11+
Publish the current branch by pushing to the remote specified by the first argument (defaulting to origin),
1212
and setting the current branch to track the upstream branch.
1313

1414
Example:
1515

1616
```shell
17+
# pushing to origin
1718
git publish
19+
20+
# pushing to fork
21+
git publish fork
1822
```
1923

2024
Compare:

doc/git-unpublish/index.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,21 @@
55
Git alias:
66

77
```git
8-
unpublish = !"git push origin :$(git current-branch)"
8+
unpublish = "!f() { git push ${1:-origin} :$(git current-branch); }; f"
99
```
1010

1111
Unpublish the current branch by deleting the
1212
remote version of the current branch.
13+
The remote name may be specified by the first argument and defaults to `origin`.
1314

1415
Example:
1516

1617
```shell
18+
# unpublish on origin
1719
git unpublish
20+
21+
# unpublish branch on fork
22+
git unpublish fork
1823
```
1924

2025
Compare:

gitalias.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1372,11 +1372,11 @@
13721372

13731373
# Publish the current branch by pushing it to the remote "origin",
13741374
# and setting the current branch to track the upstream branch.
1375-
publish = "!git push --set-upstream origin \"$(git current-branch)\""
1375+
publish = "!f() { git push --set-upstream \"${1:-origin}\" \"$(git current-branch)\"; }; f"
13761376

13771377
# Unpublish the current branch by deleting the
13781378
# remote version of the current branch.
1379-
unpublish = "!git push origin :\"$(git current-branch)\""
1379+
unpublish = "!f() { git push \"${1:-origin}\" :\"$(git current-branch)\"; }; f"
13801380

13811381
### inbound & outbound ###
13821382

0 commit comments

Comments
 (0)