git 撤销push回到任意版本
2017-03-29 14:54
113 查看
转载地址:http://blog.csdn.net/kldxcr/article/details/38563617
今天 github 上操作遇到了一个很头疼的问题,在某个文件中进行了误操作(有可能是加入了BOM头),diff 没看到差异,但是线上就是不正常显示。修改半天没用,只要回退版本。
通过
commit 的信息:
commit 后面的一串字符就是 SHA 字符。
这句命令可以回退到指定版本。不过上传的时候要注意了,如果你是:
肯定会出现这样的错误提示:
原因是你本地版本要落后于服务器上的版本(git reset 回退了嘛),如果想覆盖服务器上版本,应该加
不过这样的操作要谨慎了,先把修改的位置备份(拿出来,复制到文件夹外),完成上述操作之后再复制回来处理。 (完)
今天 github 上操作遇到了一个很头疼的问题,在某个文件中进行了误操作(有可能是加入了BOM头),diff 没看到差异,但是线上就是不正常显示。修改半天没用,只要回退版本。
通过
Git log可以查看近期
commit 的信息:
commit bcdfd65ba3f16a0647e7687f92cca25d51738d2e Author: Barret Lee <barret.china@gmail.com> Date: Mon Apr 28 01:22:27 2014 +0800 now post commit 69eeaa60c5808c143aabce4d52feb104e2e4591b Author: Barret <barret.china@gmail.com> Date: Sat Apr 26 21:03:48 2014 +0800 fix bug commit b9e4b8c697d139ec35e17be7dd353f1338e9b92e Author: Jing Lee <barret.china@gmail.com> Date: Sat Apr 26 19:35:37 2014 +0800 Update atom.xml
commit 后面的一串字符就是 SHA 字符。
git reset --hard SHA
这句命令可以回退到指定版本。不过上传的时候要注意了,如果你是:
git push -u master origin
肯定会出现这样的错误提示:
error: failed to push some refs to 'https://github.com/barretlee/barretlee.github.io.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details.
原因是你本地版本要落后于服务器上的版本(git reset 回退了嘛),如果想覆盖服务器上版本,应该加
-f,强制提交,
git push -u master origin -f
不过这样的操作要谨慎了,先把修改的位置备份(拿出来,复制到文件夹外),完成上述操作之后再复制回来处理。 (完)
相关文章推荐
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- Git的纯命令操作,Install,Clone , Commit,Push,Pull,版本回退,撤销更新,分支的创建/切换/更新/提交/合并,代码冲突
- Android 源码下载完成后,如何切换单个Git库的版本到历史任意版本?
- git回到上一版本命令
- Git 版本控制系統(3) 還沒 push 前可以做的事
- Git快速入门-git stash 暂存变更,git reset 撤销commit,git revert 回退远程版本库
- Git撤销git commit 但是未git push的修改
- git 回到上一个版本
- git 撤销已push的commit
- git回滚到上一版本(撤销上一步commit)
- git push后的撤销操作
- git撤销已经push到远端的commit
- git命令返回任意一个版本的方法
- Git 版本管理 add rm commit push pull
- Git-撤销(回退)已经add,commit或push的提交
- git完成push操作后想撤销
- Git版本控制教程 - Git查阅、撤销修改和版本回退
- Git撤销已经推送(push)至远端仓库的提交(commit)信息
- git撤销已Push到服务器的Commit