diff options
author | Jonas Smedegaard <dr@jones.dk> | 2017-04-18 11:19:17 +0200 |
---|---|---|
committer | Jonas Smedegaard <dr@jones.dk> | 2017-04-18 11:19:17 +0200 |
commit | 873d7fbd17bb5779c613aadd29e8a8de6abf26f8 (patch) | |
tree | d690ec241b7ab6946f28fabbba0b180f89e123c6 /localgit-remote-init-push | |
parent | 458cd0c185549deb869fa6abe172b577596251dd (diff) |
Support optional GIT_REMOTE, and only set default when "origin".
Diffstat (limited to 'localgit-remote-init-push')
-rwxr-xr-x | localgit-remote-init-push | 12 |
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 |