如何更优雅地切换 Git 分支

栏目: 编程工具 · 发布时间: 7年前

内容简介:在日常开发中,我们经常需要在不同的 Git 分支之间来回切换,特别是业务需求比较多的开发人员。在分支较多的情况下,切换分支时分支名的 tab 自动补全会比较糟糕,我们不免需要复制或手打分支名,那么有没有更优雅的方式了呢?为了提高切换 Git 分支的效率,我用 Golang 写了Github 地址:https://github.com/royeo/git-checkout-branch ,欢迎 star。

在日常开发中,我们经常需要在不同的 Git 分支之间来回切换,特别是业务需求比较多的开发人员。在分支较多的情况下,切换分支时分支名的 tab 自动补全会比较糟糕,我们不免需要复制或手打分支名,那么有没有更优雅的方式了呢?

为了提高切换 Git 分支的效率,我用 Golang 写了 git-checkout-branch 这个小工具,可以交互式的切换分支,并自带搜索功能,帮助你更优雅的进行分支切换。

概览

Github 地址:https://github.com/royeo/git-checkout-branch ,欢迎 star。

如何更优雅地切换 Git 分支

说明:

  • 使用箭头键 进行移动
  • 使用 jk 也可上下移动
  • 使用 / 切换搜索

安装

使用 go get 安装 git checkout-branch 命令,确保 $GOPATH/bin 路径在 PATH 中。

go get -u github.com/royeo/git-checkout-branch

如果你正在使用 GO 1.11 Module,使用以下命令进行安装:

GO111MODULE=off go get -u github.com/royeo/git-checkout-branch

建议为 checkout-branch 设置别名,例如 cb ,这样就可以直接使用 git cb 来进行分支切换。

git config --global alias.cb checkout-branch

帮助

使用 git checkout-branch help 获取帮助信息。

Checkout git branches more efficiently.

Usage:
  git checkout-branch [flags]

Flags:
  -a, --all          List both remote-tracking branches and local branches
  -r, --remotes      List the remote-tracking branches
  -n, --number       Set the number of branches displayed in the list (default 10)
      --hide-help    Hide the help information

以上所述就是小编给大家介绍的《如何更优雅地切换 Git 分支》,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对 码农网 的支持!

查看所有标签

猜你喜欢:

本站部分资源来源于网络,本站转载出于传递更多信息之目的,版权归原作者或者来源机构所有,如转载稿涉及版权问题,请联系我们

Nine Algorithms That Changed the Future

Nine Algorithms That Changed the Future

John MacCormick / Princeton University Press / 2011-12-27 / GBP 19.95

Every day, we use our computers to perform remarkable feats. A simple web search picks out a handful of relevant needles from the world's biggest haystack: the billions of pages on the World Wide Web.......一起来看看 《Nine Algorithms That Changed the Future》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

HEX CMYK 转换工具
HEX CMYK 转换工具

HEX CMYK 互转工具