Postman提供了**集合(Collections)和环境(Environments)**的基础版本控制能力,适合简单场景:
v1-users、v2-users),便于分类管理。选中集合后,点击右侧“版本”选项卡,可保存当前集合状态(输入版本名称、描述),后续可查看历史版本并回滚。v1和v2两个环境,分别设置基础URL为https://api.example.com/v1和https://api.example.com/v2。发送请求时选择对应环境,Postman会自动替换URL中的变量,实现版本切换。若需要更专业的版本管理(如团队协作、历史追溯),可将Postman集合导出为JSON文件,通过Git进行版本控制:
sudo yum install git -y .json文件(如my-api-collection.json)。cd /path/to/collection git init git add my-api-collection.json git commit -m "Add initial API collection for v1" git remote add origin https://github.com/your-username/api-collection.git git push -u origin main 后续每次修改集合后,重复git add→git commit→git push步骤,即可实现版本跟踪。若Postman的内置功能无法满足需求,可选择Bruno(开源、完全离线的API客户端),其原生支持Git版本控制:
.bru)存储,可直接提交到Git仓库,支持团队协作(通过Git Pull/Push)、历史追溯(查看每次提交的API变更)。sudo snap install bruno GET /v1/users),保存后自动生成.bru文件。.bru文件所在目录初始化Git仓库,添加文件并推送:git init git add my-api.bru git commit -m "Add API collection for v1" git remote add origin https://github.com/your-username/bruno-collection.git git push -u origin main .bru文件,即可实现API版本的版本控制。以上方法覆盖了从基础到高级的版本控制需求,可根据团队规模、协作需求选择合适的方式。