Git 推送配置是否也允许指定分支?
Does a Git a push configuration allow specifying the branch as well?
我有一个分支,它从一个遥控器拉出并推送到另一个遥控器,你使用 git branch --set-upstream-to=xxxx xxxx
设置拉回购,git config remote.origin.pushurl user@user.com:repo.git
设置推回购。
尽管拉动来自源回购的 master
分支,但 push
转到目标回购的 upstream
分支。
当我切换到分支并执行 git push
时,我收到通常的 --global push.default
消息:
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
有没有办法为特定分支指定它应该推送到远程的哪个分支,而不是 push.default
值,对于拉取也是如此?
the idea is to push to any arbitrarily named branch that is different from the branch name
只需指定一个upstream branch:
git branch --set-upstream-to my_local_branch origin/my_remote_branch
那么后续的推送就知道要推送到哪个分支了my_local_branch
.
您仍然需要设置推送策略(git config push.default simple
)
要推送到一个仓库,但从另一个仓库拉取,您可以将推送url设置为不同于pull/fetch url
git config remote.origin.pushurl /url/for/origin/repo
git config remote.origin.url /url/for/upstream/repo
这将允许使用 "one" 远程管理所有内容(实际上引用了两个不同的存储库)
您还可以更新上游分支部分的参考规范:
git config remote.origin.push refs/heads/my_local_branch:refs/heads/my_remote_branch
git config remote.origin.fetch refs/heads/my_local_branch:refs/heads/my_local_branch
我有一个分支,它从一个遥控器拉出并推送到另一个遥控器,你使用 git branch --set-upstream-to=xxxx xxxx
设置拉回购,git config remote.origin.pushurl user@user.com:repo.git
设置推回购。
尽管拉动来自源回购的 master
分支,但 push
转到目标回购的 upstream
分支。
当我切换到分支并执行 git push
时,我收到通常的 --global push.default
消息:
warning: push.default is unset; its implicit value has changed in
Git 2.0 from 'matching' to 'simple'. To squelch this message
and maintain the traditional behavior, use:
git config --global push.default matching
To squelch this message and adopt the new behavior now, use:
git config --global push.default simple
When push.default is set to 'matching', git will push local branches
to the remote branches that already exist with the same name.
有没有办法为特定分支指定它应该推送到远程的哪个分支,而不是 push.default
值,对于拉取也是如此?
the idea is to push to any arbitrarily named branch that is different from the branch name
只需指定一个upstream branch:
git branch --set-upstream-to my_local_branch origin/my_remote_branch
那么后续的推送就知道要推送到哪个分支了my_local_branch
.
您仍然需要设置推送策略(git config push.default simple
)
要推送到一个仓库,但从另一个仓库拉取,您可以将推送url设置为不同于pull/fetch url
git config remote.origin.pushurl /url/for/origin/repo
git config remote.origin.url /url/for/upstream/repo
这将允许使用 "one" 远程管理所有内容(实际上引用了两个不同的存储库)
您还可以更新上游分支部分的参考规范:
git config remote.origin.push refs/heads/my_local_branch:refs/heads/my_remote_branch
git config remote.origin.fetch refs/heads/my_local_branch:refs/heads/my_local_branch