小编Ram*_*ils的帖子

用部分名称在git中切换分支

如果我在git中有以下分支

1194-qa-server
master
remotes/origin/1178-authentication
remotes/origin/1194-qa-server
remotes/origin/HEAD -> origin/master
remotes/origin/master
Run Code Online (Sandbox Code Playgroud)

我想使用--just--切换到分支,即使需要调用脚本,例如:

switch_branch 1178
Run Code Online (Sandbox Code Playgroud)

并且脚本/解决方案应该执行以下操作

  1. git branch -a(在我的存储库中查找本地和远程的所有分支)
  2. 按给定参数过滤('1178'以上)
  3. 提取git可以使用的分支的名称
  4. 切换到那个分支

在不必手动执行所有这些步骤的情况下,建议的方法是什么?

我正在使用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 …
Run Code Online (Sandbox Code Playgroud)

git shell console bash-it

10
推荐指数
2
解决办法
3262
查看次数

ruby:optimize => phrase.split(delimiter).collect {| p | p.lstrip.rstrip}

ruby:什么是最优化的表达式来评估与结果相同的结果

phrase.split(delimiter).collect {|p| p.lstrip.rstrip }
Run Code Online (Sandbox Code Playgroud)

ruby regex

4
推荐指数
1
解决办法
673
查看次数

标签 统计

bash-it ×1

console ×1

git ×1

regex ×1

ruby ×1

shell ×1