Git 警告:refname 'xxx' 不明确
Git warning: refname 'xxx' is ambiguous
我有两个分支 'master' 和 'develop',我从 master 创建了一个新分支 'hotfix-1' 然后我将 'hotfix-1' 合并回 master ;
git checkout master
git merge --no-ff hotfix-1
为此点创建了一个标签;
git tag -a hotfix-1 -m ""
然后我从 master 切换回 develop 分支并将 'hotfix-1' 与 ;
合并
git checkout develop
git merge --no-ff hotfix-1
合并 'hotfix-1' 到开发后,我收到 "warning: refname 'hotfix-1' is ambiguous" 消息并且 它成功合并我的更改到开发 也是..我应该担心什么吗?
编辑
git show-ref --heads --tags
d97bfc563749918799d4659c43f7bffd29cf4d60 refs/heads/develop
594ea85c94f8321d372779ed3dbd5df07bdb059b refs/heads/master
ffc897f8ab19510d5ff4c67969d0f0cb97d1c4f3 refs/tags/beta-1.0
490a8c80ecec70fd2268aa0c2ad7a9beb6bf491c refs/tags/beta-1.1
644adadb43744ad1d2e0f13fc37abb6906520f8f refs/tags/hotfix-1.0.1
4c49e8d9ddc8d601ed794f307e1c29acfc84b31b refs/tags/release-1.0
从您最初的问题来看,您似乎有一个标签和一个名为 hotfix-1
的分支。当然,它们的实际名称分别是 refs/tags/hotfix-1
和 refs/heads/hotfix-1
,但是 Git 允许您使用 shorthand,在这种情况下是不明确的,因为 Git 允许您可以在 git merge
语句中使用任何 committish。事实上,当我测试这个场景时,Git 合并了标签,而不是分支。
虽然在查看 git show-ref --heads --tags
输出时不清楚,因为只有一个名为 hotfix-1.0.1
的标签,没有同名的分支。看起来您可能随后进行了更改。
这是一个例子,其中约瑟夫对发生的事情的假设实际上发生在我们身上。
git merge BranchyBranch_r2.1
warning: refname 'BranchyBranch_r2.1' is ambiguous.
实际上有一个标签和一个同名的分支 (BranchyBranch_r2.1),除此之外,有人试图通过给复制分支的标签起别名来缓解这个问题。
git show-ref --heads --tags
ac729d902578378557f9f20dbd415c5748a23230 refs/heads/BranchyBranch_r2.1
9f3d242e03837fd33f8355005e9edbee89367bef refs/heads/develop
5995987876e6a2315544bd774b546ed561f78a53 refs/heads/master
df26c94be018268e2897807c0750b5c66150750b refs/tags/BranchyBranch_r2.1
df26c94be018268e2897807c0750b5c66150750b refs/tags/BranchyBranch_r2.1Tag
如果您通过完全限定名称引用分支,则可以继续。
git merge refs/heads/BranchyBranch_r2.1
以防万一,如果您的分支和标签与存储库同名,最好从修订号创建新的分支/标签。
git checkout -b {new_branch_name} {revision}
我有两个分支 'master' 和 'develop',我从 master 创建了一个新分支 'hotfix-1' 然后我将 'hotfix-1' 合并回 master ;
git checkout master
git merge --no-ff hotfix-1
为此点创建了一个标签;
git tag -a hotfix-1 -m ""
然后我从 master 切换回 develop 分支并将 'hotfix-1' 与 ;
合并git checkout develop
git merge --no-ff hotfix-1
合并 'hotfix-1' 到开发后,我收到 "warning: refname 'hotfix-1' is ambiguous" 消息并且 它成功合并我的更改到开发 也是..我应该担心什么吗?
编辑
git show-ref --heads --tags
d97bfc563749918799d4659c43f7bffd29cf4d60 refs/heads/develop
594ea85c94f8321d372779ed3dbd5df07bdb059b refs/heads/master
ffc897f8ab19510d5ff4c67969d0f0cb97d1c4f3 refs/tags/beta-1.0
490a8c80ecec70fd2268aa0c2ad7a9beb6bf491c refs/tags/beta-1.1
644adadb43744ad1d2e0f13fc37abb6906520f8f refs/tags/hotfix-1.0.1
4c49e8d9ddc8d601ed794f307e1c29acfc84b31b refs/tags/release-1.0
从您最初的问题来看,您似乎有一个标签和一个名为 hotfix-1
的分支。当然,它们的实际名称分别是 refs/tags/hotfix-1
和 refs/heads/hotfix-1
,但是 Git 允许您使用 shorthand,在这种情况下是不明确的,因为 Git 允许您可以在 git merge
语句中使用任何 committish。事实上,当我测试这个场景时,Git 合并了标签,而不是分支。
虽然在查看 git show-ref --heads --tags
输出时不清楚,因为只有一个名为 hotfix-1.0.1
的标签,没有同名的分支。看起来您可能随后进行了更改。
这是一个例子,其中约瑟夫对发生的事情的假设实际上发生在我们身上。
git merge BranchyBranch_r2.1
warning: refname 'BranchyBranch_r2.1' is ambiguous.
实际上有一个标签和一个同名的分支 (BranchyBranch_r2.1),除此之外,有人试图通过给复制分支的标签起别名来缓解这个问题。
git show-ref --heads --tags
ac729d902578378557f9f20dbd415c5748a23230 refs/heads/BranchyBranch_r2.1
9f3d242e03837fd33f8355005e9edbee89367bef refs/heads/develop
5995987876e6a2315544bd774b546ed561f78a53 refs/heads/master
df26c94be018268e2897807c0750b5c66150750b refs/tags/BranchyBranch_r2.1
df26c94be018268e2897807c0750b5c66150750b refs/tags/BranchyBranch_r2.1Tag
如果您通过完全限定名称引用分支,则可以继续。
git merge refs/heads/BranchyBranch_r2.1
以防万一,如果您的分支和标签与存储库同名,最好从修订号创建新的分支/标签。
git checkout -b {new_branch_name} {revision}