如果我在 git 中有以下分支
1194-qa-server
master
remotes/origin/1178-authentication
remotes/origin/1194-qa-server
remotes/origin/HEAD -> origin/master
remotes/origin/master
我想使用 --just-- 数字切换到分支,即使这需要调用脚本 例如:
switch_branch 1178
并且脚本/解决方案应该执行以下操作
- git branch -a (在我的存储库中查找所有本地和远程分支)
- 按给定参数过滤(上面的“1178”)
- 提取git可以使用的分支名称
- 切换到那个分支
无需手动执行所有这些步骤的推荐方法是什么?
我正在使用 Mac OSX,如果这很重要的话。
更新——bash-it (github.com/revans/bash-it) 符合我的目的
Welcome to Bash It!
Here is a list of commands you can use to get help screens for specific pieces of Bash it:
rails-help list out all aliases you can use with rails.
git-help list out all aliases you can use with git.
todo-help list out all aliases you can use with todo.txt-cli
brew-help list out all aliases you can use with Homebrew
aliases-help generic list of aliases.
plugins-help list out all functions you have installed with bash-it
bash-it-plugins summarize bash-it plugins, and their installation status
reference <function name> detailed help for a specific function