我试图理解一个git命令.
在我的本地存储库中,我目前正在使用master.
我在一个叫做遥控器的地方origin,住着两个分店:master和review.但是,我有另一个叫做的遥控器review......
我的问题是:当我运行以下命令时会发生什么?
git push review
Run Code Online (Sandbox Code Playgroud)
它是否将更改推送到review同一个遥控器上的分支?或者是否将更改推送到具有名称的另一个遥控器review?
我了解这可能会造成混淆。您最好为分支机构和远程站点选择不同的名称。
运行时git push review,您实际上是在使用以下语法
git push <repository> [<refspec>...]
Run Code Online (Sandbox Code Playgroud)
但您忽略了可选<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).
Run Code Online (Sandbox Code Playgroud)
因此,运行时会发生什么情况git push review取决于您的Git配置。跑
git config remote.review.push
Run Code Online (Sandbox Code Playgroud)
如果找到匹配项,则相应的值指示您在运行时会发生什么git push review。如果找不到匹配项,则Git使用值push.default来确定要做什么;跑
git config push.default
Run Code Online (Sandbox Code Playgroud)
查看push.default当前所处的模式。有关其的更多详细信息push.default,请参考“ git push”的默认行为(未指定分支)