summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xlocalgit-remote-init-push12
1 files changed, 9 insertions, 3 deletions
diff --git a/localgit-remote-init-push b/localgit-remote-init-push
index e171b8e..7cff8ab 100755
--- a/localgit-remote-init-push
+++ b/localgit-remote-init-push
@@ -6,7 +6,7 @@ PRG=$(basename "$0")
showhelp() {
cat <<EOF
-Usage: $PRG PROJECT [GIT_HOST [SSH_CONN]]
+Usage: $PRG PROJECT [GIT_HOST [SSH_CONN [GIT_REMOTE]]]
Initialize remote git, push local git, and set as default remote.
@@ -18,8 +18,13 @@ Initialize remote git, push local git, and set as default remote.
SSH_CONN hostname for ssh, optionally with user + "@" prepended
default: GIT_HOST
+ GIT_REMOTE name for local repository set
+ default: "origin"
+
Full remote path becomes SSH_USER@SSH_HOST:/srv/git/GIT_HOST/PROJECT.git
+When local repository set is "origin" it is marked as default remote.
+
Examples:
$PRG myproject
$PRG some/subproject git.example.org me@shell.example.org
@@ -46,7 +51,8 @@ done
PROJECT=${1-$(showhelp; exit1 "project name missing")}
GIT_HOST=${2:-source.$(dnsdomainname --domain)}
SSH_CONN=${3:-$GIT_HOST}
+GIT_REMOTE=${4:-origin}
ssh "$SSH_CONN" git init --bare --shared /srv/git/"$GIT_HOST"/"$PROJECT".git
-git remote add origin "$SSH_CONN":/srv/git/"$GIT_HOST"/"$PROJECT".git
-git push --set-upstream origin master
+git remote add "$GIT_REMOTE" "$SSH_CONN":/srv/git/"$GIT_HOST"/"$PROJECT".git
+[ origin != "$GIT_ORIGIN" ] || git push --set-upstream "$GIT_REMOTE" master