git笔记

82 阅读1分钟

push后回滚版本

目前线上仓库已经有3次commit,我们想要回到第一次commit image.png

  1. 首先回滚版本
git reset --hard 版本号(最少六位)

image.png

2.提交到线上仓库

git push --force //force强制提交

image.png

  1. 回滚完成 可以使用git log查看commit
    会只剩下第一次commit

使用git reflog查看 将会展示所有commit以及回滚版本记录

合并分支多个提交变为一个

--squash

 git merge --squash branch
 git commit -m "message"