【发布时间】:2019-04-21 08:05:35
【问题描述】:
我有一个用
修改的 aliases.sh 文件alias gc='git checkout'
在检查一个长分支名称时,如果我输入
gc <branchstring> + TAB ,自动完成不起作用,以便显示完整的分支名称。
【问题讨论】:
标签: git
我有一个用
修改的 aliases.sh 文件alias gc='git checkout'
在检查一个长分支名称时,如果我输入
gc <branchstring> + TAB ,自动完成不起作用,以便显示完整的分支名称。
【问题讨论】:
标签: git
我查看了 this thread 中的所有内容,试图使其适用于并定制 kpsfoo 所说的内容,但适用于 Windows 10 操作系统。
步骤如下:
1) 从
复制 git-completion.bash 文件<your git install folder>/etc/git-completion.bash
到
C:\Users\<YourUserName>\git-completion.bash
2) 添加这行代码:
source ~/git-completion.bash 到您的 aliases.sh 文件
(可以在<your git install folder>\etc\profile.d找到)
3) 添加alias gc='git checkout'
&
在 aliases.sh 文件中 source ~/git-completion.bash 行之后的任意位置添加 __git_complete gco _git_checkout。
4) 重新启动您的 git bash 并享受您的别名自动完成功能!
示例:
如果我有一个分支 VeryVeryLongBranchName 并且我目前在 dev 分支上,并且想要切换到它,而不是输入
git checkout VeryVeryLongBranchName我只能打字
gc Very +TAB 键 相当于上面的指令。
alias ga="git add"
alias gb='git branch'
alias gba="git branch -a"
alias gc='git checkout'
alias gcb='git checkout -b'
alias gcam='git commit -a -m'
alias gm='git merge --no-ff'
alias gps='git push wpdev dev'
alias gpsm='git push wpdev master'
alias gpl='git pull wpdev dev'
alias gplm='git pull wpdev master'
alias st='git status'
alias l='git log --graph --pretty='\''%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset'\'' --abbrev-commit'
alias last='log -1 HEAD'
alias gs='git stash'
# Enable the __git_complete function to autocomplete aliases once you press TAB
source ~/git-completion.bash
__git_complete ga _git_add
__git_complete gc _git_checkout
__git_complete gm _git_merge
__git_complete gb _git_branch
__git_complete gba _git_branch
__git_complete l _git_log
case "$TERM" in
xterm*)
# The following programs are known to require a Win32 Console
# for interactive usage, therefore let's launch them through winpty
# when run inside `mintty`.
for name in node ipython php php5 psql python2.7
do
case "$(type -p "$name".exe 2>/dev/null)" in
''|/usr/bin/*) continue;;
esac
alias $name="winpty $name.exe"
done
;;
esac
-值得注意的是:alias gm='git merge --no-ff' 与 __git_complete gm _git_merge 配合得很好(当输入 gm 加上分支名称中的字符串并按 TAB 时,它将自动完成, 并且,在你运行命令后,合并将考虑 --no-ff 规则)
【讨论】:
zsh 无需任何手动调整即可工作。
<git-installation-folder>/mingw64/share/git/completion/git-completion.bash