git 配置默认推送不适用于名称不是 origin 的远程
git config default push does not work for remote with name other than origin
如果我以这种方式添加远程仓库地址并将其设置为默认地址:
git init .
remoteName="origin"
dstUrl='location-of-initialized-bare-repository'
git remote add "$remoteName" "$dstUrl"
git config push.default current
touch masterfile
git add masterfile
git commit -m 'first'
git push
git checkout -b feature
touch feautrefile
git add feautrefile
git commit -m 'second'
git push
一切正常。
但是当我以不同的方式设置远程名称时,即:
remoteName="something"
fatal: No configured push destination.
我认为遥控器的名称是任意的,可以设置为任何值,在行为上没有任何区别,但似乎对于 git push
使用的默认遥控器,没有任何参数,它必须是 origin
或者我遗漏了什么?也许 git 默认查找 origin
但如果名称不同,我需要告诉它不同的名称是默认值?
如何设置与 origin
不同的默认遥控器名称?
该解决方案应适用于将来创建的新分支。
只是添加一个新的远程 URL/name 不会使本地分支推送到它。
您需要至少使用一次新遥控器:
git push -u newRemoteName myBranch
参见“”
确实将 branch.myBranch.remote
设置为 newRemoteName
,然后启用简单的 git push
工作。
第一次推送成功是因为它默认为一个名为(按照惯例)“origin
”的远程。
参见 git push
When the command line does not specify where to push with the <repository>
argument, branch.*.remote
configuration for the current branch is consulted to determine where to push.
If the configuration is missing, it defaults to origin
.
如果我以这种方式添加远程仓库地址并将其设置为默认地址:
git init .
remoteName="origin"
dstUrl='location-of-initialized-bare-repository'
git remote add "$remoteName" "$dstUrl"
git config push.default current
touch masterfile
git add masterfile
git commit -m 'first'
git push
git checkout -b feature
touch feautrefile
git add feautrefile
git commit -m 'second'
git push
一切正常。 但是当我以不同的方式设置远程名称时,即:
remoteName="something"
fatal: No configured push destination.
我认为遥控器的名称是任意的,可以设置为任何值,在行为上没有任何区别,但似乎对于 git push
使用的默认遥控器,没有任何参数,它必须是 origin
或者我遗漏了什么?也许 git 默认查找 origin
但如果名称不同,我需要告诉它不同的名称是默认值?
如何设置与 origin
不同的默认遥控器名称?
该解决方案应适用于将来创建的新分支。
只是添加一个新的远程 URL/name 不会使本地分支推送到它。
您需要至少使用一次新遥控器:
git push -u newRemoteName myBranch
参见“
确实将 branch.myBranch.remote
设置为 newRemoteName
,然后启用简单的 git push
工作。
第一次推送成功是因为它默认为一个名为(按照惯例)“origin
”的远程。
参见 git push
When the command line does not specify where to push with the
<repository>
argument,branch.*.remote
configuration for the current branch is consulted to determine where to push.
If the configuration is missing, it defaults toorigin
.