【问题标题】:Git push Refspecs: `refs/heads/*:refs/heads/origin` vs `refs/heads/*:refs/heads/*`Git push Refspecs:`refs/heads/*:refs/heads/origin` vs `refs/heads/*:refs/heads/*`
【发布时间】:2019-10-26 23:21:42
【问题描述】:

哪个 push Refspec (Git) 是正确的?或者两者都是正确的?有什么区别?

  1. refs/heads/*:refs/heads/origin/*
  2. refs/heads/*:refs/heads/*

我更喜欢 (1),因为它引用远程名称(来源),我不明白 (2) 是什么意思(但我看到它在一些手册中使用!)。

【问题讨论】:

    标签: git refspec git-refspec


    【解决方案1】:

    使用refs/heads/*:refs/heads/origin/*git push origin master 将扩展为git push origin refs/heads/master:refs/heads/origin/master。它将在远程存储库中创建或更新一个名为 origin/master 的分支。这是有效的,但refs/heads/origin/masterrefs/remotes/origin/master 会产生歧义。在某些情况下,它可能会导致错误。

    第二个有效。使用remote.origin.push=refs/heads/*:refs/heads/*git push 扩展为git push origin refs/heads/master:refs/heads/master refs/heads/dev:refs/heads/devgit push origin master 扩展为git push origin refs/heads/master:refs/heads/master

    【讨论】:

    • 非常抱歉!当然,我的意思是 refs/heads/*:refs/heads/origin/* 代表 (1)
    • @CodeComplete 使用 refs/heads/*:refs/heads/origin/*git push origin master 将扩展为 git push origin refs/heads/master:refs/heads/origin/master。它将在远程存储库中创建或更新一个名为 origin/master 的分支。这是有效的,但refs/heads/origin/masterrefs/remotes/origin/master 会产生歧义。在某些情况下,它可能会导致错误。
    猜你喜欢
    • 2017-12-07
    • 2018-12-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-06-29
    • 1970-01-01
    • 2022-08-15
    • 1970-01-01
    相关资源
    最近更新 更多