Git-02_版本回退
来源:互联网 发布:淘宝助理类目空白 编辑:程序博客网 时间:2024/06/05 15:59
删除仓库
说明
删除掉.git目录即可删除repository
操作
$ cd e:
$ cd git_repository/
$ ls -a
. .. .git hello.txt
$ rm -rf .git hello.txt
$ ls -a
. ..
准备工作
初始化仓库
$ git init
Initialized empty Git repository in e:/git_repository/.git/
创建文件
$ touch hello.txt
提交文件
$ git add hello.txt
$ git commit hello.txt -m "create hello.txt"
[master (root-commit) 3ec0011] create hello.txt
1 file changed, 0 insertions(+), 0 deletions(-)
create mode 100644 hello.txt
修改文件
添加数据
数据
the first line: I like git!
$ echo 'the first line: I like git!' >> hello.txt
$ cat hello.txt
the first line: I like git!
$ git add hello.txt
$ git commit hello.txt -m "append a line: I like git"
$ git status
On branch master
nothing to commit, working directory clean
添加数据
数据
the second line: Git is powerful~
$ echo 'the second line: Git is powerful~' >> hello.txt
$ cat hello.txt
the first line: I like git!
the second line: Git is powerful~
$ git status
$ git add hello.txt
$ git commit hello.txt -m "append a line: Git is powerful"
查看版本
命令
$ git log
$ git log --pretty=oneline
$ git log --pretty=oneline --abbrev-commit
示例
$ git log
commit f69a305be8d203da324992b88e8de00127c53581
Author: wuqinfei <wuqinfei@qq.com>
Date: Mon Nov 10 19:42:21 2014 +0800
append a line: Git is powerful
commit 49cc630ed86f6f24c73df113c42a4f0763d691f6
Author: wuqinfei <wuqinfei@qq.com>
Date: Mon Nov 10 19:35:10 2014 +0800
append a line: I like git
commit 3ec0011e5c26da1250abe1e6c551add42343eaa2
Author: wuqinfei <wuqinfei@qq.com>
Date: Mon Nov 10 19:31:39 2014 +0800
create hello.txt
$ git log --pretty=oneline
f69a305be8d203da324992b88e8de00127c53581 append a line: Git is powerful
49cc630ed86f6f24c73df113c42a4f0763d691f6 append a line: I like git
3ec0011e5c26da1250abe1e6c551add42343eaa2 create hello.txt
说明
每提交一次就创建一个快照, 这个快照在Git中被称为commit
commit f69a...581
commit id, 版本号
版本号是由 SHA1 计算出来的一个非常大的十六进制数字
回退版本
命令
$ git reset --hard HEAD^
版本
HEAD
表示当前版本, 0
HEAD^
表示上一个版本, -1
HEAD^^
表示上上一个版本, -2
HEAD~100
表示上100个版本, -100
示例
回退到上一版本
$ git log --pretty=oneline
f69a305be8d203da324992b88e8de00127c53581 append a line: Git is powerful
49cc630ed86f6f24c73df113c42a4f0763d691f6 append a line: I like git
3ec0011e5c26da1250abe1e6c551add42343eaa2 create hello.txt
$ git reset --hard HEAD^
HEAD is now at 49cc630 append a line: I like git
$ git log --pretty=oneline
49cc630ed86f6f24c73df113c42a4f0763d691f6 append a line: I like git
3ec0011e5c26da1250abe1e6c551add42343eaa2 create hello.txt
后悔了,想回到最新版
$ git reset --hard f69a305be8d203da3
HEAD is now at f69a305 append a line: Git is powerful
$ git log --pretty=oneline
f69a305be8d203da324992b88e8de00127c53581 append a line: Git is powerful
49cc630ed86f6f24c73df113c42a4f0763d691f6 append a line: I like git
3ec0011e5c26da1250abe1e6c551add42343eaa2 create hello.txt
历史操作
说明
记录你的每一次命令
示例
$ git reflog
f69a305 HEAD@{0}: reset: moving to f69a305be8d203da3
49cc630 HEAD@{1}: reset: moving to HEAD^
f69a305 HEAD@{2}: commit: append a line: Git is powerful
49cc630 HEAD@{3}: commit: append a line: I like git
3ec0011 HEAD@{4}: commit (initial): create hello.txt
- Git-02_版本回退
- git 回退版本
- Git-版本回退
- git 版本回退
- git回退版本
- git版本回退
- Git版本回退
- git版本回退
- Git版本回退
- git 版本回退
- Git 版本回退
- git版本回退
- git版本回退
- Git回退版本
- git版本回退
- git版本回退
- git版本回退
- git 版本回退
- windows API 开发飞机订票系统(一)
- 【Cocos2d-x】实现可上下左右无限滚动的背景
- 面试(处女面)
- java开发_模仿百度文库_OpenOffice2PDF_注意事项
- 脚本入门--类的方法
- Git-02_版本回退
- android程序开发中网络地址问题
- JSP详细篇——Servlet(二)
- 浅析onsubmit校验表单时利用ajax的return false无效问题
- 设计模式之禅-模板方法模式
- HDU 1004 Let the Balloon Rise
- mysql任意ip访问
- JSP详细篇——Servlet过滤器和监听器
- UIWindow和UIView