我在 git 配置中将 push.default
选项设置为 simple
,因为我认为这更有意义,这样我就不会在我的 git 上创建不需要的分支远程存储库,如果我不经意地推送了一些东西。
但是,有时,我知道此推送将在远程创建一个新分支,因此我想告诉 git 对于此特定命令,我愿意将 Push.default 配置更改为 current
(以便它创建一个与我当前所在的分支同名的分支),但仅限于该命令。
他们可以使用 git 来做到这一点吗?或者我应该创建一个 bash 别名?
最佳答案
您可以尝试 -c
option of the git command :
git -c "push.default=current" push -u origin newBranch
使用:
-c <name>=<value>
Pass a configuration parameter to the command. The value given will override values from configuration files.
The<name>
is expected in the same format as listed by git config (subkeys separated by dots).
关于git - 他们是否可以仅针对当前推送将 Push.default 设置为 `current`,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31648939/