我想要理解一个git命令。
在我的本地代码库中,我当前在master
分支上。
我有一个名为origin
的远程仓库,其中有两个分支:master
和review
。
但是,我还有另一个名为review
的远程仓库...
我的问题是:当我运行以下命令时会发生什么?
git push review
它是否将更改推送到同一远程的
review
分支?
还是将更改推送到另一个名称为review
的远程?git push review
时,实际上使用了以下语法。git push <repository> [<refspec>...]
<refspec>...
参数。因此,在这里,git push
将review
理解为远程而不是分支。所以,如果没有全部更新,git push review
将会把改动推送到名为review
的远程。git-push
手册中相关的段落:When the command line does not specify what to push with
<refspec>... arguments or --all, --mirror, --tags options, the
command finds the default <refspec> by consulting remote.*.push
configuration, and if it is not found, honors push.default
configuration to decide what to push (See gitlink:git-config[1] for
the meaning of push.default).
git push review
时,其结果取决于您的Git配置。请执行相应操作。git config remote.review.push
如果匹配成功,那么对应的值决定了你运行git push review
时会发生什么。如果没有匹配成功,则Git使用push.default
的值来确定该如何操作;运行
git config push.default
查看当前push.default
模式。有关push.default
的详细信息,请参阅未指定分支的“git push”默认行为。
http://git-scm.com/docs/git-push
[<repository> [<refspec>...]]