Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

起语:

版权声明: 腾讯课堂->零声学院.
我只是用来方便学习 && 复习!!! 我只是一个学习者, 从来不对我说过的话负责, 大家看到谨慎参考!!!
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

版本回退-已经提交到remote仓库

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

总结================================================================
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

具体操作

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
模拟场景
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
这是另外一个同事的提交
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
如果现在我想回滚到 红色矩形版本, 可是又能不影响其他同事的提交, 解决方案: 拉取分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
注意: 不能影响其他同事的提交. 只能影响自己的
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
查看我目前所在的分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
拉取我想要回滚的版本, 添加一个分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
查看我当前所在的分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
查看代码的内容
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
我也不知道这个操作有啥用
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
切换到 master 这个分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
查看代码内容
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
老师突然发现自己, 分支拉取错误了
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
老师忘记了(正常), 在尝试删除刚刚拉取的分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
老师忘记了(正常), 在尝试删除刚刚拉取的分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
这才是真真的删除刚拉取的分支

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
这次才是, 需要拉取的分支
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

-b #新建分支
reset_to_xxxxxxxx #分支名
xxxxx #分支的id

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
当前的分支就会到, 新建的分支上
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
查看代码

=========================================
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
拉取最近的代码, 注意左上角的位置
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
git log #查看日志
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
查看它之前做了那些修改, +printf(“add feature : #FT-1234566”);
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
vim main.cpp

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
git status #查看当前的状态
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
提交 commitGit 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
切换到 master 分支上
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
记得切换到 master分支
把 reset_to_f812621xxxx(分支)内容 merge 到master(分支)上

发现有冲突(这里提示是在main.cpp上)

vim main.cpp
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
需要手动修改冲突
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
commit #提交到本地仓库
Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
push #上传到远程仓库

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)
我也不知道这是什么操作
版本回滚, 是一件很危险的事情!!!

结语:

Git 版本管理之git神器版本回退(版本回退-已经提交到remote仓库)

时间: 2020-08-18