I'm using the bash completion script for git. However, there are situations where it doesn't work. Say I have a branch foo-branch, and a file foo-file. If I have changes in the file which I want to throw away, I'll often do:
git checkout fo<tab>
This completes immediately to foo-branch. Usually, if there are multiple completion options, I get a bell, and another tab will show me the options. Is there any way to get the completion to work like that in this case as well? Or does the git completion always take precedence over the file name completion?
Edit: I've waded through the bash man page and found -o plusdirs
, which I added to the complete
directive. This works; I'll have to try it for a whi开发者_如何学编程le to see if it doesn't cause problems with commands that don't take a file name argument.
To separate filename-completion from ref-completion add -- as a separator:
git checkout foo -- file.c
or
git checkout -- file.c
.
It may seem simple, but I avoid problems like this by not making branch names that conflict.
精彩评论