Git 推送 Refspecs:`refs/heads/*:refs/heads/origin` 与 `refs/heads/*:refs/heads/*`

Git push Refspecs: `refs/heads/*:refs/heads/origin` vs `refs/heads/*:refs/heads/*`

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

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

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

使用 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