git - 为什么 "git remote add"创建 "fetch"refspec 而不是 "push"refspec?

标签 git

根据git config的文档,支持以下两项:

remote.<name>.fetch
    The default set of "refspec" for git-fetch(1). See git-fetch(1).

remote.<name>.push
    The default set of "refspec" for git-push(1). See git-push(1).

但是,当我发出

git remote add <name> <url>

我看到只添加了获取引用规范。为什么“推”在这里被视为二等?原理是什么?

最佳答案

虽然看起来可以更好地记录它,但它可能与此有关:

push.default

Defines the action git push should take if no refspec is given on the command line, no refspec is configured in the remote, and no refspec is implied by any of the options given on the command line.

Possible values are:

  • nothing – do not push anything.
  • matching – push all matching branches. All branches having the same name in both ends are considered to be matching. This is the default.
  • tracking – push the current branch to its upstream branch.
  • current – push the current branch to a branch of the same name.

默认推送 refspec(s) 是由 push.default 设置控制的,因此,除非您想要的设置不是默认设置,否则不需要每个远程推送引用规范。但是,如果您希望一个 Remote 以一种方式工作而另一个 Remote 以不同方式工作,您可以使用每个 Remote 推送 refspecs 指定详细信息。

关于git - 为什么 "git remote add"创建 "fetch"refspec 而不是 "push"refspec?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24759468/

相关文章:

git - 在 macOS 查看 homebrew 上安装后通过 SSH 连接到 Bitbucket repo

windows - 如何从 Git 存储库中删除特定文件名的所有实例?

git - 如何授予用户访问 gitolite 中所有存储库的权限?

git - Git checkout 双破折号的含义

macos - 如何在 Mac 上的 $PATH 中添加/usr/local/bin

git - git-rev-list 的排序

git - 致命: unable to access 'https://github.com/usename/my-project.git/' : The requested URL returned error: 403 Mac

git - 快捷方式 git 分支 checkout

git - 为什么在我执行 shell 脚本时,我的 cmd.exe 窗口中会出现 git 提示符?

git - 有没有办法在命令行上报告 git 贡献?