Git 中模糊搜索分支名称并创建本地跟踪分支

本文记录一次通过命令行模糊搜索远程分支名称,然后再创建本地跟踪分支的操作。

背景

新的迭代开始了,团队会创建新的迭代分支,但是我只记得分支名称包含了"246",需要什么命令才能把远程分支拉到本地呢?

下面是我的操作步骤。

操作步骤

1、拉取最新的分支:

bash 复制代码
git pull

2、模糊搜索分支,以"246"为例:

bash 复制代码
git br -a | grep '246'

将会看到输出,比如下面这样的:

复制代码
 remotes/origin/feature/S246-1

3、创建本地分支(并跟踪)

bash 复制代码
git sw -c feature/s246-1 origin/feature/S246-1

输出:

复制代码
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。

相关推荐
阿民不加班14 小时前
【Git】git拉取远端但是本地存在不想提交文件处理
git
Selina K15 小时前
在windows安装git
git
周杰伦fans1 天前
如何将 Feature 分支同步到 Master 主分支:一次完整的 Git 合并实战
git
jiayi_19991 天前
git创建new branch
git
__Witheart__1 天前
通过交互式 Rebase 合并部分提交到远程分支的操作步骤
git
魔都吴所谓1 天前
【Tools】Repo 工具完整使用手册
git
tianyuanwo1 天前
跨 Gerrit 项目迁移分支并保留完整历史:一份可操作的 Git 指南
git·代码迁移
玄奕子1 天前
VS Code 上传 GitHub 全流程(Windows 环境):HTTP 与 SSH 两种方案(含常见报错排查)
git·http·ssh·github·嵌入式开发
一只游鱼1 天前
如何让本地的敏感配置文件不上传到git仓库
git·elasticsearch
渣渣馬2 天前
shell的if多条件
git·ssh