gpt4 book ai didi

Git "Fetch URL"和 "Push URL",有什么区别?

转载 作者:IT王子 更新时间:2023-10-29 00:47:53 40 4
gpt4 key购买 nike

什么时候某个远程的 Fetch URL 和 Push URL 不一样?

例如,当我为一个名为 central 的远程运行 git remote show central 时,输出如下:

* remote central
Fetch URL: aoberoi@example.com:/home/aoberoi/Repositories/example.git
Push URL: aoberoi@example.com:/home/aoberoi/Repositories/example.git
HEAD branch: master
Remote branch:
master tracked

我只是不明白为什么我要从两个不同的 URL 获取和推送,这适用于哪种类型的工作流程?

最佳答案

我不确定您的意思,因为您的示例包含 2 个相同 URL,但是用于推送和 pull 的 URLS 可能不同,因为:

  • 协议(protocol)问题:参见Git protocols : url 将略微不同,因为并非每个协议(protocol)都支持推送操作(例如 http,除非是 smart http )
  • 中间仓库:您可以推送到另一个仓库,它将成为真正的“中央”仓库和您的仓库之间的“中间人”。然后可以执行某些操作(例如通过接收后 Hook ),如果这些操作(如“单元测试”、“静态代码分析”...... ) 顺利通过。
    有关此类用法的示例,请参阅:
    "What is the cleverest use of source repository that you have ever seen? "。

也就是说,commit 697f652 (Git 2.3.1+,2015 年第一季度/第二季度)作者:Git 维护者 Junio C Hamano ( gitster )请提及:

It seems to be a common mistake to try using a single remote (e.g. 'origin') to fetch from one place (i.e. upstream) while pushing to another (i.e. your publishing point).

That will never work satisfactorily, and it is easy to understand why if you think about what refs/remotes/origin/* would mean in such a world. It fundamentally cannot reflect the reality.
If it follows the state of your upstream, it cannot match what you have published, and vice versa.

The documentation wasn't clear that "remote.<nick>.pushURL" and "remote.<nick>.URL" are there to name the same repository accessed via different transports, not two separate repositories.

关于Git "Fetch URL"和 "Push URL",有什么区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4468234/

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