本文记录一次通过命令行模糊搜索远程分支名称,然后再创建本地跟踪分支的操作。
背景
新的迭代开始了,团队会创建新的迭代分支,但是我只记得分支名称包含了"246",需要什么命令才能把远程分支拉到本地呢?
下面是我的操作步骤。
操作步骤
1、拉取最新的分支:
bash
git pull
2、模糊搜索分支,以"246"为例:
bash
git br -a | grep '246'
将会看到输出,比如下面这样的:
bash
remotes/origin/feature/S246-1
3、创建本地分支(并跟踪)
bash
git sw -c feature/s246-1 origin/feature/S246-1
输出:
csharp
Updating files: 100% (448/448), done.
branch 'feature/s246-1' set up to track 'origin/feature/S246-1' by rebasing.
Switched to a new branch 'feature/s246-1'
说明
以上命令中的 br、sw 是我定义的别名,分别对应 branch、switch。