Git版本回退操作

  • 通过“git reset --hard CommitID”命令回退到指定 CommitID 的版本,如下示例命令:
git reset --hard 8c38ccaed0c6a7e55aa17e8c730f0f3a9a79ae76

注:“git reset --hard”是强制回退到上一个版本或特定版本,此操作不可逆,在使用之前请慎重考虑清楚。

  • 回退到指定提交
git revert [CommitID]

执行完成回退操作后,执行强制推送到远程仓库,以更新当前远程仓库版本为实际回退的版本,命令如下:

git push origin HEAD --force

注:在执行强制推送命令时需要开通 “ForcePush”权限,否则会弹出如下提示:

! [remote rejected] HEAD -> master (TF401027: You need the Git 'ForcePush' permission to perform this action.

权限设定:

Project Settings >> Repos >> Repositories >> 要设定权限的远程仓库 >> Permissions 设定Tag,将“Force push (rewrite history, delete branches and tags)”权限设定为“Allow

 

  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值