Git in Windows Bash shell: Autocompletion isn’t working the way I expect

  Kiến thức lập trình

I’m using Git in the Windows Git Bash shell. I need clarification of how autocomplete works. The documentation I’ve found talks about how to enable it, but seems to assume that “well, it just works.” But it doesn’t work the way I expect.

Here’s a case where this got me in trouble. I wanted to check out a branch named 24.05-release-notes-js4506. I entered “git checkout 24.05″ and pressed tab. I saw Bash fill in a bunch more characters with digits at the end, so I assumed that it had autocompleted the branch name for me. The repo had no other branches named 24.05-anything, so what else could it possibly do?

I continued working for a while before I realized that Git had not changed branches. Looking back, I found that Bash had autocompleted the branch name up to but not including the last character. Git said, “that’s not a branch name,” and did nothing.

This would make sense if there existed another branch whose name was the same except for the last character. But there isn’t. Why did autocomplete stop where it did?