切换到test分支下,并拉去最新的test分支代码
git checkout test
git pull
把本地的test分支强制推送到远端master
git push origin test:master -f
可能会出现如下错误,因为master分支是受保护的,需要将master分支受保护给关闭掉,(覆盖完成之后要记得把受保护给重新打开),然后再执行 git push origin test:master -f 即可
MacBook-Pro:xxx xxx$ git push origin test:master -f
Total 0 (delta 0), reused 0 (delta 0)
remote: GitLab: You are not allowed to force push code to a protected branch on this project.
To http://git.xxx.git
! [remote rejected] test -> master (pre-receive hook declined)
error: failed to push some refs to 'http://git.xxx.git'
删除本地的master分支,检出最新master 分支到本地就可以了
git branch -d master
git checkout master
如果不想删除,切换到master,然后把HEAD指向master最新版本也可以
git checkout master
git reset --hard origin/master