Yesterday, I created a branch from a branch, pushed it to origin, and merged it back into master. You can see that here:
$ history |less
8358 git co master
8359 commit # shortcut that adds all and commits
8360 push # shortcut that `git push`'s
8361 git lg # shortcut that logs my output
8362 git co 1600
8363 git co -b 1601
8364 npm run test
8365 npm run test
8366 npm run test
8367 npm run test
8368 npm run test
8369 npm run test
8370 npm run test
8371 npm run test
8372 npm run test
8373 npm run test
8374 npm run test
8375 npm run test
8376 npm run test
8377 ./release.sh
8378 ./release.sh
8379 commit
8380 push
8381 git push --set-upstream origin 1601
8382 git lg
8383 git co master
8384 git merge --no-ff -
8385 git st
8386 commit
8387 push
I'm including irrelevant stuff in this list so I don't accidentally cut out something that is relevant; as you can see, all of this history is sequential. Here is everything in my history that refers to 1601:
$ history | grep 1601
1601 npm run test
8363 git co -b 1601
8381 git push --set-upstream origin 1601
8438 git co 1601
8445 git co 1601
8446 git show-ref 1601
8447 history | grep 1601
8449 git show-ref | grep 1601
8458 git show-ref --heads --tags | grep 1601
8460 history | grep 1601
8461 history | grep (1601|merge)
8462 history | grep -p (1601|merge)
8464 history | grep -E (1601|merge)
8466 history | grep -E -e (1601|merge)
8467 history | grep -E -e \(1601|merge\)
8468 history | grep -E -e '(1601|merge)'
8469 history | grep -E -e '(1601|merge|master)'
8470 history | grep -E -e '(1601|1601|merge|master)'
8472 history | grep -E -e '(1601|1601|merge|master)'
8474 history | grep -E -e '(1601|1601|merge|master)'
8480 history | grep 1601
Somehow, after these steps, whenever I git co 1601
, it gives me this warning:
$ git co 1601
warning: refname '1601' is ambiguous.
Already on '1601'
Your branch is up to date with 'origin/1601'.
I've been googling for a while, looking for others that have had this issue, but none of them seem to have the same situation. Here is what I've looked at that hasn't helped:
- Git warning: refname 'xxx' is ambiguous
- Git: refname 'master' is ambiguous
- git refname 'origin/master' is ambiguous
- http://thesimplesynthesis.com/post/git-error-warning-refname-originbranch-name-is-ambiguous
The following output is to help with troubleshooting:
$ git show-ref | grep 1601
137b74c8ff6807f07bb32ba0d2f76a3ba287e981 refs/heads/1601
137b74c8ff6807f07bb32ba0d2f76a3ba287e981 refs/remotes/origin/1601
$ git tag -l
$ git show-ref --heads --tags | grep 1601
137b74c8ff6807f07bb32ba0d2f76a3ba287e981 refs/heads/1601
cat .git/config
# this is the only place where it mentions 1601
[branch "1601"]
remote = origin
merge = refs/heads/1601
$ cat .git/config | grep 1601
[branch "1601"]
merge = refs/heads/1601
$ git checkout 1601 --
warning: refname '1601' is ambiguous.
Already on '1601'
Your branch is up to date with 'origin/1601'.
$ git ls-remote . \*1601*
beea6ee68d6fe6b4f5222c0efe0e206e23af993c refs/heads/1601
beea6ee68d6fe6b4f5222c0efe0e206e23af993c refs/remotes/origin/1601
$ git show 1601 # this only shows one log message
warning: refname '1601' is ambiguous.
commit beea6ee68d6fe6b4f5222c0efe0e206e23af993c (HEAD -> 1601, origin/1601)
...
$ git --version
git version 2.31.1
$ type git
git is hashed (/usr/bin/git)
FWIW, I am using cygwin on Windows.
Why am I getting this warning, how do I get rid of it, and how do I prevent it in the future?