File tree Expand file tree Collapse file tree 1 file changed +11
-5
lines changed
Expand file tree Collapse file tree 1 file changed +11
-5
lines changed Original file line number Diff line number Diff line change @@ -41,16 +41,22 @@ test -z "$user" && abort "git config user.email required"
4141# branch
4242
4343branch=${1-$(git symbolic-ref HEAD | sed ' s/refs\/heads\///' )}
44+ remote=$( git config branch." $branch " .remote)
45+ if [ -z " $remote " ]; then
46+ echo ' no upstream found, push to origin as default'
47+ remote=" origin"
48+ fi
49+ [ " $remote " == " ." ] && abort " the upstream should be a remote branch."
4450
4551# make sure it's pushed
4652
47- git push origin " $branch " || abort " failed to push $branch "
53+ git push " $remote " " $branch " || abort " failed to push $branch "
4854
49- origin =$( git config remote.origin .url)
50- if [[ $origin == git@* ]]; then
51- project=${origin ##*: }
55+ remote_url =$( git config remote." $remote " .url)
56+ if [[ " $remote_url " == git@* ]]; then
57+ project=${remote_url ##*: }
5258else
53- project=${origin # https://*/ }
59+ project=${remote_url # https://*/ }
5460fi
5561project=${project% .git}
5662
You can’t perform that action at this time.
0 commit comments