Git 命令行学习二(撤回提交)


查看提交履历
$ git log
$ nano myweb.html
...
...
$ git add myweb.html
$ git commit -m "added code."
$ git log
$ git log --oneline //一行显示
$ git log -p	//详细显示
$ git log --stat	//每次提交信息统计
$ git log --help

把握Git状态
知识点
	•	git status
	•	git checkout -- [file]

实战演习
$ nano myweb.html //修改文件
...
...
$ git status	//查看文件状态

On branch master
Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git checkout -- <file>..." to discard changes in working directory)

	modified:   myweb.html


$ git checkout -- myweb.html
$ git status
$ nano myweb.html	//修改文件
...
...
$ git add myweb.html
On branch master
Changes to be committed:
  (use "git reset HEAD <file>..." to unstage)

	modified:   myweb.html
$ git reset HEAD myweb.html //撤回(到本地仓库)已经添加到索引去的文件
$ git checkout -- myweb.html	//撤销修改
$ git status

比较修改内容

知识点
	•	git diff [--cached]

实战演习
$ nano myweb.html	//修改文件
...
...
#工作文件夹比较
$ git diff
#把修改文件追加到索引区
$ git add myweb.html
#无法比较工作文件夹的修改文件
$ git diff
#索引区比较
$ git diff --cached

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值