大数据全系列 教程
1869个小节阅读:467.7k
目录
408考研
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
git reset --hard [局部版本号] :前进后退版本
Git切换版本,底层其实是移动的HEAD指针,原理如下图所示:
xxxxxxxxxx
$ vim gtjin.txt
# 修改后的内容如下:
$ cat gtjin.txt
hello git,hello gtjin,edit v3
hello git,hello gtjin
hello git,hello gtjin
new Line :edit v2
$ git add gtjin.txt
warning: LF will be replaced by CRLF in gtjin.txt.
The file will have its original line endings in your working directory
$ git commit -m "commit 3" gtjin.txt
warning: LF will be replaced by CRLF in gtjin.txt.
The file will have its original line endings in your working directory
[master a5fb5ad] commit 3
1 file changed, 1 insertion(+), 1 deletion(-) # 增加一行、删除一行 表示修改一行
Administrator@SC-201911261404 MINGW64 /d/GitSpace/FirstGitRepos (master)
$ git reflog
a5fb5ad (HEAD -> master) HEAD@{0}: commit: commit 3
b488da1 HEAD@{1}: commit: commit 2
24d7cd1 HEAD@{2}: commit (initial): commit 1
Administrator@SC-201911261404 MINGW64 /d/GitSpace/FirstGitRepos (master)
$ git reset --hard b488da1 # 切换到commit 2对应的版本号
HEAD is now at b488da1 commit 2
Administrator@SC-201911261404 MINGW64 /d/GitSpace/FirstGitRepos (master)
$ cat gtjin.txt
hello git,hello gtjin
hello git,hello gtjin
hello git,hello gtjin
new Line :edit v2
# 在切换回到 commit 3后对应的版本号
$ git reset --hard a5fb5ad
HEAD is now at a5fb5ad commit 3
Administrator@SC-201911261404 MINGW64 /d/GitSpace/FirstGitRepos (master)
$ cat gtjin.txt
hello git,hello gtjin,edit v3
hello git,hello gtjin
hello git,hello gtjin
new Line :edit v2