我想使用全局 gitconfig 文件设置我的 git (TortoiseGIT),以便克隆存储库时的默认远程名称不是“origin”,而是我定义的其他一些文本(例如“foo”)。
这可能吗?有哪些指令?
谢谢
编辑:这样做的目的是,我为不同的独立任务(文档!)创建几个较小的存储库,并且我厌倦了每次修改远程名称,因为它可以使用其他用户的共享来使用。所以远程的名称应该是我机器的名称,以避免与其他 git 版本混淆。我知道这不是最佳实践,但这就是生活:(。
I want to set up my git (TortoiseGIT) using the global gitconfig file such that the default remote name when I clone a repository is not "origin" but some other text defines by me (e.g. "foo").
Is this possible? Which directives are the ones?
Thanks
Edit: The intention of that is, that I create several smaller repositories for different, independent tasks (documentation!) and I am tired of every time modifying the name of the remote since it is available using shares to other users. So the name of the remote should be my machine's name to avoid confusing the other git versions. I know this is not best practice but that's life :(.
发布评论
评论(2)
没有全局配置选项。当您克隆“origin”存储库时,您必须使用 git clone --origin foo
There is no global config option. You will have to use
git clone --origin foo <source>
to change the name of the "origin" repository when you clone it:Git 2.30.0 (2020-12-27) 引入了
clone.defaultRemoteName
配置值,描述如下:同时
git-clone
的 >--origin 命令行选项将其描述更改为:要获取该值,请使用
默认的 origin 似乎是通过源代码中的硬编码添加的,因为如果您没有此配置值,则会收到错误(缺少密钥)。但是,如果您至少使用 Git 2.18.0 (2018-06-21),则有
--default
命令行选项git-config
,简化为:如何设置value 取决于您想要设置它的范围,但它与任何其他配置值没有什么不同,因此关于该主题(设置 Git 配置值)应该有很多帮助。
Git 2.30.0 (2020-12-27) introduced
clone.defaultRemoteName
configuration value that is described the following:while at the same time the
--origin
command-line option ofgit-clone
changed its description to:To get the value use
The default
origin
seems to be added by a hardcode in the source code since if you don't have this configuration value you get an error (missing key). However, if you are using at least Git 2.18.0 (2018-06-21) then there is a--default
command-line option togit-config
, simplifying to:How to set the value depends on the scope you want to set it in but it is no different than any other configuration value, so there should be plenty of help on the topic (of setting Git configuration values).