Restore the git master branch to the specified version

1. View the log and copy the commit number A you want to restore to

Assuming A=30c8404a0c9a58452c23f509e7ee19eace06c50d

git log

2. Restore the code to version A

git reset --hard 30c8404a0c9a58452c23f509e7ee19eace06c50d

3. Force update to remote branch

git push -f origin master

4. If there is an error in 3,
Insert picture description here
go to gitlab to check whether the project master branch is protected

After going to the Setting>Registry>Protected BranchesUnProtect master branch

Retry step 3

git push -f origin master

Remember to restore the protected branch

After going to the Setting>Registry>Protected BranchesProtect master branch

Guess you like

Origin blog.csdn.net/jianleking/article/details/104300860