git merge错误的分支后又提交到远程仓库了,该怎么恢复回去
某草草
某草草 2017-05-02 09:50:50
0
2
888

1.deploy分支是生产环境的分支,master是主开发分支。
2.deploy分支有几个文件配置和master分支的不一样,通常都是将master分支合并到deploy分支,并不会改变deploy分支下的配置文件信息。
3.不小心把deploy分支合并进了master分支,导致master分支下的配置文件被改成了deploy分支下的,并且做了push,远程master分支下的配置文件也成deploy下的了。
4.改回了master分支下的配置文件,重新做了push,但是现在不敢往deploy分支合并了,因为担心master分支下的配置会替换掉deploy下的。
现在想恢复master分支之前的版本,以及远程仓库内的版本。该怎么做?

某草草
某草草

reply all(2)
某草草

In fact, this is very easy. The author can perform the rollback operation locally first:

  • Retrieve the hash value corresponding to the previous master status through the submission log

git log

Copy its hash value, if it is 664d6cf35a7.

  • Then time travel and return to the previous state

git reset --hard 664d6cf35a7

After rolling back, delete the remote master branch:

git push origin --delete master

If you cannot delete it, you can first set the default branch to another branch remotely, such as deploy. If the poster's remote warehouse is on github, you can click on the setting->branches-.default branches of the corresponding warehouse and modify it.

Then run the above command to delete the remote master branch.

After deletion, you can now push the master branch again, which will re-establish a master branch in the remote warehouse. After pushing, change the remote default warehouse to master again.

The current situation is basically the same as before.

大家讲道理

Roll back the local branch > Delete the remote branch > Push the local branch (that is, create a new remote branch)

However, this method is not suitable for protected branches such as master. You can use the following method:

Rewind local branch > Force push local branch (force push to overwrite remote branch content)

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!