@@ -139,14 +139,19 @@ install_nvm_from_git() {
139
139
fi
140
140
fi
141
141
142
+ local remote
143
+ remote=" $( git config --global clone.defaultRemoteName || true) "
144
+ if [ -z " $remote " ]; then
145
+ remote=origin
146
+ fi
142
147
local fetch_error
143
148
if [ -d " $INSTALL_DIR /.git" ]; then
144
149
# Updating repo
145
150
nvm_echo " => nvm is already installed in $INSTALL_DIR , trying to update using git"
146
151
command printf ' \r=> '
147
152
fetch_error=" Failed to update nvm with $NVM_VERSION , run 'git fetch' in $INSTALL_DIR yourself."
148
153
else
149
- fetch_error=" Failed to fetch origin with $NVM_VERSION . Please report this!"
154
+ fetch_error=" Failed to fetch $remote with $NVM_VERSION . Please report this!"
150
155
nvm_echo " => Downloading nvm from git to '$INSTALL_DIR '"
151
156
command printf ' \r=> '
152
157
mkdir -p " ${INSTALL_DIR} "
@@ -156,9 +161,9 @@ install_nvm_from_git() {
156
161
nvm_echo >&2 ' Failed to initialize nvm repo. Please report this!'
157
162
exit 2
158
163
}
159
- command git --git-dir=" ${INSTALL_DIR} /.git" remote add origin " $( nvm_source) " 2> /dev/null \
160
- || command git --git-dir=" ${INSTALL_DIR} /.git" remote set-url origin " $( nvm_source) " || {
161
- nvm_echo >&2 ' Failed to add remote "origin " (or set the URL). Please report this!'
164
+ command git --git-dir=" ${INSTALL_DIR} /.git" remote add " $remote " " $( nvm_source) " 2> /dev/null \
165
+ || command git --git-dir=" ${INSTALL_DIR} /.git" remote set-url " $remote " " $( nvm_source) " || {
166
+ nvm_echo >&2 ' Failed to add remote "' " $remote " ' " (or set the URL). Please report this!'
162
167
exit 2
163
168
}
164
169
else
@@ -170,10 +175,10 @@ install_nvm_from_git() {
170
175
fi
171
176
fi
172
177
# Try to fetch tag
173
- if command git --git-dir=" $INSTALL_DIR " /.git --work-tree=" $INSTALL_DIR " fetch origin tag " $NVM_VERSION " --depth=1 2> /dev/null; then
178
+ if command git --git-dir=" $INSTALL_DIR " /.git --work-tree=" $INSTALL_DIR " fetch " $remote " tag " $NVM_VERSION " --depth=1 2> /dev/null; then
174
179
:
175
180
# Fetch given version
176
- elif ! command git --git-dir=" $INSTALL_DIR " /.git --work-tree=" $INSTALL_DIR " fetch origin " $NVM_VERSION " --depth=1; then
181
+ elif ! command git --git-dir=" $INSTALL_DIR " /.git --work-tree=" $INSTALL_DIR " fetch " $remote " " $NVM_VERSION " --depth=1; then
177
182
nvm_echo >&2 " $fetch_error "
178
183
exit 1
179
184
fi
0 commit comments