[{"createTime":1735734952000,"id":1,"img":"hwy_ms_500_252.jpeg","link":"https://activity.huaweicloud.com/cps.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=V1g3MDY4NTY=&utm_medium=cps&utm_campaign=201905","name":"华为云秒杀","status":9,"txt":"华为云38元秒杀","type":1,"updateTime":1735747411000,"userId":3},{"createTime":1736173885000,"id":2,"img":"txy_480_300.png","link":"https://cloud.tencent.com/act/cps/redirect?redirect=1077&cps_key=edb15096bfff75effaaa8c8bb66138bd&from=console","name":"腾讯云秒杀","status":9,"txt":"腾讯云限量秒杀","type":1,"updateTime":1736173885000,"userId":3},{"createTime":1736177492000,"id":3,"img":"aly_251_140.png","link":"https://www.aliyun.com/minisite/goods?userCode=pwp8kmv3","memo":"","name":"阿里云","status":9,"txt":"阿里云2折起","type":1,"updateTime":1736177492000,"userId":3},{"createTime":1735660800000,"id":4,"img":"vultr_560_300.png","link":"https://www.vultr.com/?ref=9603742-8H","name":"Vultr","status":9,"txt":"Vultr送$100","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":5,"img":"jdy_663_320.jpg","link":"https://3.cn/2ay1-e5t","name":"京东云","status":9,"txt":"京东云特惠专区","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":6,"img":"new_ads.png","link":"https://www.iodraw.com/ads","name":"发布广告","status":9,"txt":"发布广告","type":1,"updateTime":1735660800000,"userId":3},{"createTime":1735660800000,"id":7,"img":"yun_910_50.png","link":"https://activity.huaweicloud.com/discount_area_v5/index.html?fromacct=261f35b6-af54-4511-a2ca-910fa15905d1&utm_source=aXhpYW95YW5nOA===&utm_medium=cps&utm_campaign=201905","name":"底部","status":9,"txt":"高性能云服务器2折起","type":2,"updateTime":1735660800000,"userId":3}]
<>使用背景
目前这家公司有 dev,test两个分支。
我接到新需求,于是建了新的业务分支 branch1。因为需要和前端联调需要把接口发布到开发环境,然后就把 branch1 的分支合并到 dev 分支。并且
push 到仓库了。
可是,据了解,另外一个高级同事说他也在dev开发,可是联调在test。。。导致test环境会因为没有新需求相关表而报错。
<>解决办法
如果您需要撤销已经合并到远程分支的提交,可以考虑以下步骤:
* 首先使用 git log 查看要回滚的提交记录,找到需要回滚的 commit id。 * c0416c40 (origin/dev) Merge
branch 'xxx_20230730' into dev |\ | * 67464d72 (origin/xxx_20230730,
xxx_20230730) [update] xxx | * 309fb501 [feature] xxx | * efb6c81a [feature]
xxx | * 7cd1c383 [feature] xxx
commit id = c0416c40
* 然后使用 git revert 命令回滚合并提交,如下所示: git revert -m 1 c0416c40
其中 -m 1 用于指定要回滚的提交是主分支(master)的一次合并提交。
我是将含有 Merge branch 字眼的提交分支撤销了,也就是c0416c40。这个操作会删除该提交分支提交的相关文件
* 完成上述步骤后,使用 git push 命令将回滚操作推送到远程分支上。注意,此处可能需要使用强制推送选项 -f,具体命令为: git push -f
origin<branch-name>
其中 <branch-name> 是您想要回滚的远程分支的名称。
* 最后,通知其他开发者关于您对远程分支进行了撤销操作的更改,以便他们在本地分支上拉取最新更改。
结果就是提交历史会增加一行说明
* dabb039c (HEAD -> dev) Revert "Merge branch 'xxx_20230730' into dev"