在平常開發中,咱們常常須要在不一樣的 Git 分支之間來回切換,特別是業務需求比較多的開發人員。在分支較多的狀況下,切換分支時分支名的自動補全會比較糟糕,咱們難免須要複製或手打分支名,那麼有沒有更優雅的方式了呢?git
爲了提升切換 Git 分支的效率,我用 Golang 寫了 git-checkout-branch
這個小工具,能夠交互式的切換分支,並自帶搜索功能,幫助你更優雅的進行分支切換。github
Github 地址:github.com/royeo/git-c… ,歡迎 star。curl
說明:ide
↓
↑
→
←
進行移動j
和 k
也可上下移動/
切換搜索ctrl + c
退出能夠直接下載安裝:工具
curl -sSL https://github.com/royeo/git-checkout-branch/releases/download/v0.2.0/git-checkout-branch-`uname -s`-`uname -m` -o /usr/local/bin/git-checkout-branch && chmod +x /usr/local/bin/git-checkout-branch
複製代碼
也能夠使用 go get
安裝,確保 $GOPATH/bin
路徑在 PATH
中。ui
go get -u github.com/royeo/git-checkout-branch
複製代碼
建議爲 checkout-branch
設置別名,例如 cb
,這樣就能夠直接使用 git cb
來進行分支切換。url
git config --global alias.cb checkout-branch
複製代碼
使用 git checkout-branch help
獲取幫助信息。spa
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
複製代碼