[Git]checkout 指定版本

Task:知道commit号,如何checkout 指定版本

1. 切换到指定的branch

2. 下载head

3. 查看log找到需要的版本

4. 根据header checkout

 1 [[email protected]80 ebs]$ git branch
 2 * consistencyCheck
 3   master
 4 [[email protected]80 ebs]# git checkout master
 5 Switched to branch ‘master‘
 6 [[email protected]80 ebs]# git branch
 7   consistencyCheck
 8 * master
 9 [[email protected]80 ebs]# git checkout HEAD
10 [[email protected]80 ebs]# git log |more
11 commit e24385f84866f0010d3317164b23be9e6054f283
12 Merge: 31d7dc5 41ac93d
13 Author: wa357 <[email protected]>
14 Date:   Wed Apr 26 13:08:11 2017 +0800
15
16     merge modify_election
17
18 commit 41ac93d383abf2e3b83a2df1cd3c201877867d2d
19 Author: lij <[email protected]>
20 Date:   Mon Apr 24 16:00:15 2017 +0800
21
22       modify the position of calling
23
24 commit 40b81hpc6685c7340106206fa171d0611767d40f93b
25 [[email protected]80 ebs]# git checkout e24385f84866f0010d3317164b23be9e6054f283
26 Note: checking out ‘e24385f84866f0010d3317164b23be9e6054f283‘.
27
28 You are in ‘detached HEAD‘ state. You can look around, make experimental
29 changes and commit them, and you can discard any commits you make in this
30 state without impacting any branches by performing another checkout.
31
32 If you want to create a new branch to retain commits you create, you may
33 do so (now or later) by using -b with the checkout command again. Example:
34
35   git checkout -b new_branch_name
36
37 HEAD is now at e24385f... merge modify_election_datanode_algorithm
38 [[email protected]80 ebs]#
39 [[email protected]80 ebs]# git branch
40 * (detached from e24385f)
41   consistencyCheck
42   master
时间: 2024-08-19 07:58:02

[Git]checkout 指定版本的相关文章

使用git checkout 指定git代码库上的指定分支

由于以前一直是在用svn,到狼厂,大家都用Git.哥的开发环境:IntelliJ 说说简单的操作过程吧. 1.检出Git代码库 cd到指定目录 git clone http://..../android.git clone远程的代码到本地 2.git branch -r 展示该Git库下的所有branch 3.git checkout -b master_3.0 这里的master_3.0是上一步中branch列表中的origin/master_3.0,也是我们想check出来的分支. 常用Gi

git下载指定版本的代码

1. git fetch https://github.com/angular/angular.js.git v1.5.8 或 2. git pull https://github.com/angular/angular.js.git v1.5.8 -------------------------------------------------------------------------------------------------------------- Git中从远程的分支获取最新

git回到指定版本命令

git reset 是指将当前head的内容重置,不会留log信息. git reset HEAD filename  从暂存区中移除文件 git reset --hard HEAD~3  会将最新的3次提交全部重置,就像没有提交过一样. git reset --hard [commit哈希值](38679ed709fd0a3767b79b93d0fba5bb8dd235f8) 回退到 38679ed709fd0a3767b79b93d0fba5bb8dd235f8 版本 根据--soft --

[git] 更新到某个指定版本

[git] 更新到某个指定版本 - Vanquisher - 博客频道 - CSDN.NET ??? [git] 更新到某个指定版本??? 2015-09-06 09:30 527人阅读 评论(0) 收藏 举报??? 分类:??? ProjectManage(1)??? 作者同类文章X ??? 版权声明:本文为博主原创文章,未经博主允许不得转载. ??? 比如: ??????? repo forall -c ' git clean -dfx;git reset --hard HEAD ' 2>&am

在 Git 中 Checkout 历史版本

昨天写代码的时候,误删了一个文件.今天发现的时候,commit 已经 push 到版本库了.本想用 git reset 回退版本,找回文件后重新提交.但是想起 Git 是一个版本控制系统哎,直接从版本库里 checkout 出某个文件的历史版本不就好了? 想法挺好,但是很久没用这个功能,自己已经不记得具体的命令了.于是查了下手册,把和 checkout 历史版本有关的几个命令都记录一下. 从某个历史版本创建新的分支 在 Git 中从当前分支创建并检出新分支的命令是 git checkout -b

[Git] 获取指定的历史版本代码

首先 ,把项目 clone 到其他文件夹下 git clone [email protected]:skyming/BMAdScrollView.git 然后查看指定历史版本 tree 的 SHA checkout 即可,哎,程序员,需要什么学什么... git checkout b0362a895d39061c0bc6f05c575af47de1b3f702 然后就顺利切到指定的分支版本了... 原文地址:https://www.cnblogs.com/jiu0821/p/9270145.ht

git更新Activemq在远程github上指定版本的源码步骤

第一步:根据地址克隆源码 (activemq-5.9) $  git  clone   https://github.com/apache/activemq.git 第二步:查看远程源码的版本清单 (activemq-5.9) $  git  branch  -a 第三步: 根据指定的远程版本创建本地分支 (activemq-5.9) $  git  checkout  -b  activemq-5.9  origin/activemq-5.9 第四步:确认或拉去该版本最新的代码 (active

Git 将代码回到指定版本

将代码回到hash为1fbcb7ea3b43df60c639875d2bb68e20b451059e的版本 git checkout 1fbcb7ea3b43df60c639875d2bb68e20b451059e 用下面代码 你还可以将指定版本设置为一个分支 git branch test2 1fbcb7ea3b43df60c639875d2bb68e20b451059e 这样你只需 git checkout test2 就回到指定分支了 原文地址:https://www.cnblogs.co

git回溯到指定版本

git log命令查看仓库日志 然后使用git checkout 命令 例如回溯到上图中的版本 git checkout 12db5d6fd138922a8aaf2214c84cb3af702dd8bb (也可以只书写日志中的前7位) git checkout 12db5d6 只为成功找方法,不为失败找理由.大胆的尝试,下一个fun就是你的fun!