gpt4 book ai didi

git - 为什么 git clone --bare 和 --origin 不兼容?

转载 作者:太空狗 更新时间:2023-10-29 13:43:41 27 4
gpt4 key购买 nike

我确定一定有充分的理由,但我不明白为什么我不能在裸 repo 中设置我的来源名称。

最佳答案

2013 年:作为 jthil comments , 自 git 1.2.0 (January 2006) 以来实现

clone: do not create remotes/origin nor origin branch in a bare repository.
It is simply pointless, since no merges will ever happen in such a repository.

这并不妨碍您添加一个 Remote ,如git1.6.0 (August 2008)使用 --mirror 选项显示。

The command line git clone --mirror $URL is now a short-hand for:

$ git clone --bare $URL
$ (cd $(basename $URL) && git remote add --mirror origin $URL)

2022 年更新:git clone --bare--origin 兼容!

在 Git 2.39 之前(2022 年第四季度,9 年后),“git clone( man ) 不喜欢看到 --bare--origin 选项在没有充分理由的情况下一起使用。

情况已经不同了:

参见 commit 3b910d6 (2022 年 9 月 22 日)Jeff King (peff) .
(由 Junio C Hamano -- gitster -- merge 于 commit 7aeb0d4,2022 年 10 月 10 日)

clone: allow "--bare" with "-o"

Reported-by: John A. Leuenhagen
Signed-off-by: Jeff King

We explicitly forbid the combination of "--bare" with "-o", but there doesn't seem to be any good reason to do so.
The original logic came as part of e6489a1 ("clone: do not accept more than one -o option.", 2006-01-22, Git v1.2.0 -- merge), but that commit does not give any reason.

Furthermore, the equivalent combination via config is allowed:

git -c clone.defaultRemoteName=foo clone ...

and works as expected.
It may be that this combination was considered useless, because a bare clone does not set remote.origin.fetch (and hence there is no refs/remotes/origin hierarchy).
But it does set remote.origin.url, and that name is visible to the user via "git fetch origin"(man), et

关于git - 为什么 git clone --bare 和 --origin 不兼容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19434441/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com