git 的版本回滚
当用git clone 复制远程代码库到本地时,使用 git branch 只能看到默认库(master),当远程库有多个分支时,可以使用 git branch -a 查看全部的分支,
然后git checkout 分支名 来切换分支
参考:
http://blog.csdn.net/xqs83/article/details/7382074
http://www.wiloon.com/wordpress/?p=2582
http://blog.csdn.net/arkblue/article/details/9568249
git代码库回滚: 指的是将代码库某分支退回到以前的某个commit id
【本地代码库回滚】:
git reset --hard commit-id :回滚到commit-id,讲commit-id之后提交的commit都去除
git reset --hard HEAD~3:将最近3次的提交回滚
【远程代码库回滚】:
这个是重点要说的内容,过程比本地回滚要复杂
应用场景:自动部署系统发布后发现问题,需要回滚到某一个commit,再重新发布
原理:先将本地分支退回到某个commit,删除远程分支,再重新push本地分支
操作步骤:
1、git checkout the_branch
2、git pull
3、git branch the_branch_backup //备份一下这个分支当前的情况
4、git reset --hard the_commit_id //把the_branch本地回滚到the_commit_id 只有使用--hard才会更改本地,要不只更新暂存区,硬盘上不变
5、git push origin :the_branch //删除远程 the_branch 这个方法在新版本上不能用,
可以参见这个方法:http://zengrong.net/post/1746.htm
6、git push origin the_branch //用回滚后的本地分支重新建立远程分支
7、git push origin :the_branch_backup //如果前面都成功了,删除这个备份分支
如果使用了gerrit做远程代码中心库和code review平台,需要确保操作git的用户具备分支的push权限,并且选择了 Force Push选项(在push权限设置里有这个选项)
另外,gerrit中心库是个bare库,将HEAD默认指向了master,因此master分支是不能进行删除操作的,最好不要选择删除master分支的策略,换用其他分支。如果一定要这样做,可以考虑到gerrit服务器上修改HEAD指针。。。不建议这样搞
原文:http://www.cnblogs.com/qualitysong/archive/2012/11/27/2791486.html
图解git 不错:http://www.cnblogs.com/hnrainll/archive/2013/03/19/2968449.html
git 的版本回滚的更多相关文章
- git远程版本回滚方法【转】
step1:本地代码回滚到上一版本(或者指定版本) git reset --hard HEAD~1 step2:加入-f参数,强制提交,远程端将强制跟新到reset版本 git push -f ori ...
- git版本回滚
本地版本回滚 git reset --hard <版本号> (git log 可查看版本号,版本号不用写全) 远程仓库版本回滚 先在本地将版本回滚 ,然后git push -f 强制提交
- Git远程库版本回滚
在git的一般使用中,如果发现错误的将不想staging的文件add进入index之后,想回退取消,这就叫做git代码库回滚: 指的是将代码库某分支退回到以前的某个commit id.可以使用命令:g ...
- git如何正确回滚代码
git如何正确回滚代码 方法一,删除远程分支再提交 ①首先两步保证当前工作区是干净的,并且和远程分支代码一致 $ git co currentBranch $ git pull origin curr ...
- git 远程分支回滚
git代码库回滚: 指的是将代码库某分支退回到以前的某个commit id [本地代码库回滚]: git reset --hard commit-id :回滚到commit-id,讲commit-id ...
- Git误操作 git reset强制回滚 恢复commit方法
参考: 找回Git中丢失的Commit Git误操作 git reset强制回滚 恢复commit方法 使用Git时,常有误操作,在Commit之后又执行了git reset --hard HEAD强 ...
- git---远程仓库版本回滚
开发中,发现有错误版本提交带远程分支master,怎么处理? 1 简介 最近在使用git时遇到了远程分支需要版本回滚的情况,于是做了一下研究,写下这篇博客. 2 问题 如果提交了一个错误的版本,怎么回 ...
- git本地代码库回滚(webstorm下)
git本地代码库回滚(webstorm下) 1. 场景 添加了一个文件[file-for-test.js]到git的控制下(并没有push到远程分支上) 进行了三次修改,并分别进行了三次commit( ...
- TortoiseSVN 版本回滚
尝试用TortoiseSVN进行版本回滚,回滚到的版本和实际的内容有出入,可能是点了太多次给点乱了,囧~ 不过发现一个比较靠谱的方法,如下: 右键点击文件TortoiseSVN->showlog ...
随机推荐
- c++ 字符串工具类
#include <string> #include "util.h" namespace strtool{ std::string trim(const std::s ...
- SpringMVC注解@RequestParam(转)
鸣谢:http://shawnccx.iteye.com/blog/730239 -------------------------------------------------- 在SpringM ...
- @Entity设置实体lazy = false
问题描述 在通过Hibernate查询Bean信息时报以下异常信息: org.hibernate.LazyInitializationException: could not initialize p ...
- javascript禁用与启用select标签(实用版)
<html><head><script type="text/javascript">function disable() { docume ...
- linux ubuntu卸载软件
1.通过deb包安装的情况: 安装.deb包: 代码:sudo dpkg -i package_file.deb反安装.deb包: 代码:sudo dpkg -r package_name 2.通过a ...
- MVC项目总结(别人的好文章)
引用 http://www.cnblogs.com/xling/archive/2012/07/11/2587002.html
- mac 用 brew
mac 下用 brew 安装插件, 有重复的不会再次安装,比xmap模式好
- SPRING IN ACTION 第4版笔记-第九章Securing web applications-004-对密码加密passwordEncoder
一. 1.Focusing on the authentication query, you can see that user passwords are expected to be stored ...
- POJ3687——Labeling Balls(反向建图+拓扑排序)
Labeling Balls DescriptionWindy has N balls of distinct weights from 1 unit to N units. Now he tries ...
- SQL查询性能分析之(not in)、(and not)、()、(!=)性能比较
SQL查询性能分析之(not in).(and not).().(!=)性能比较 SQL Server Bruce 3年前 (2013-01-08) 3284浏览 0评论 <:article c ...