git基本命令--status, add, diff, commit, log
git status:
git status命令的输出十分详细,但其用语有些繁琐。 如果你使用 git status -s 命令或 git status --short 命令,你将得到一种更为紧凑的格式输出:
$ git status -s
M README
MM Rakefile
A lib/git.rb
M lib/simplegit.rb
?? LICENSE.txt
- ??:新添加,未跟踪
- 右M:被修改,未放入暂存区
- 左M:被修改,放入暂存区
- A:新添加,放入暂存区
git status -v 将会显示详细的diff情况。
git add:
$ git add -i
# 交互模式
staged unstaged path *** Commands ***
: status : update : revert : add untracked
: patch : diff : quit : help
What now>
git diff:
a-----, b+++++
git diff
a=staged, b=workspace git diff --cached
a=repository, b=staged git diff --cached = git diff --staged
git difftool
使用 git difftool --tool= 命令来设置 Git Diff 插件。
比较两个commit之间的区别:(待验证)
$ git diff 07659f9169f6fe 5817e240edb1ed
$ git difftool 07659f9169f6fe 5817e240edb1ed
git commit:
git commit -a 跳过使用暂存区
git commit --amend 重新提交
$ git commit -m 'initial commit'
$ git add forgotten_file
$ git commit --amend
git commit --amend 只针对修改上一次的提交,如果想修改前几次的提交,需要配合git rebase -i,详见 git-重写历史
git log:
一个常用的选项是 -p,用来显示每次提交的内容差异。 你也可以加上 -2 来仅显示最近两次提交:
$ git log -p -
如果你想看到每次提交的简略的统计信息,你可以使用:
$ git log --stat
commit ca82a6dff817ec66f44342007202690a93763949
Author: Scott Chacon <schacon@gee-mail.com>
Date: Mon Mar :: - changed the version number Rakefile | +-
file changed, insertion(+), deletion(-) commit 085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7
Author: Scott Chacon <schacon@gee-mail.com>
Date: Sat Mar :: - removed unnecessary test lib/simplegit.rb | -----
file changed, deletions(-) commit a11bef06a3f659402fe7563abf99ad00de2209e6
Author: Scott Chacon <schacon@gee-mail.com>
Date: Sat Mar :: - first commit README | ++++++
Rakefile | +++++++++++++++++++++++
lib/simplegit.rb | +++++++++++++++++++++++++
files changed, insertions(+)
$ git log --pretty=oneline
ca82a6dff817ec66f44342007202690a93763949 changed the version number
085bb3bcb608e1e8451d4b2432f8ecbe6306e7e7 removed unnecessary test
a11bef06a3f659402fe7563abf99ad00de2209e6 first commit
$ git log --pretty=format:"%h - %an, %ar : %s"
ca82a6d - Scott Chacon, years ago : changed the version number
085bb3b - Scott Chacon, years ago : removed unnecessary test
a11bef0 - Scott Chacon, years ago : first commit
|
|
提交对象(commit)的完整哈希字串 |
|
|
提交对象的简短哈希字串 |
|
|
树对象(tree)的完整哈希字串 |
|
|
树对象的简短哈希字串 |
|
|
父对象(parent)的完整哈希字串 |
|
|
父对象的简短哈希字串 |
|
|
作者(author)的名字 |
|
|
作者的电子邮件地址 |
|
|
作者修订日期(可以用 --date= 选项定制格式) |
|
|
作者修订日期,按多久以前的方式显示 |
|
|
提交者(committer)的名字 |
|
|
提交者的电子邮件地址 |
|
|
提交日期 |
|
|
提交日期,按多久以前的方式显示 |
|
|
提交说明 |
$ git log --pretty=format:"%h %s" --graph
* 2d3acf9 ignore errors from SIGCHLD on trap
* 5e3ee11 Merge branch 'master' of git://github.com/dustin/grit
|\
| * 420eac9 Added a method for getting the current branch.
* | 30e367c timeout code and tests
* | 5a09431 add timeout protection to grit
* | e1193f8 support for heads with slashes in them
|/
* d6016bc require time for xmlschema
* 11d191e Merge branch 'defunkt' into local
| 选项 | 说明 |
|---|---|
|
|
按补丁格式显示每个更新之间的差异。 |
|
|
显示每次更新的文件修改统计信息。 |
|
|
只显示 --stat 中最后的行数修改添加移除统计。 |
|
|
仅在提交信息后显示已修改的文件清单。 |
|
|
显示新增、修改、删除的文件清单。 |
|
|
仅显示 SHA-1 的前几个字符,而非所有的 40 个字符。 |
|
|
使用较短的相对时间显示(比如,“2 weeks ago”)。 |
|
|
显示 ASCII 图形表示的分支合并历史。 |
|
|
使用其他格式显示历史提交信息。可用的选项包括 oneline,short,full,fuller 和 format(后跟指定格式)。 |
$ git log --oneline --decorate --graph --all * f57d39d (HEAD, test, master) add 4.txt
* c682659 add 3.txt
* 9431a1e (tag: v1) m 2
* 3deaae5 m aa.txt
* ee32f3c 2
* 07233d2 1
git基本命令--status, add, diff, commit, log的更多相关文章
- git 命令 git status add rm commit mv
1.查看 git 仓库文件改动状态 Git 仓库内文件改动有 4 种状态,除了 Unmodified 状态的文件因为并未改动默认没有状态不做显示之外,其他文件改动状态都可以通过 git status ...
- Git基本操作(add,commit的理解)
1.创建仓库 ——创建工作目录(Working Directory):git三种副本:工作目录(Working Direcotry),暂存区域(Stage,索引(Index)),仓库(History) ...
- [原]git的使用(一)---建立本地仓库、add和commit、status和git diff、版本回退使用git reset
在window下已经安装了git的环境 1.建立本地仓库 mkdir test #建立test目录 cd test #进入目录 git init # ...
- [Git] 008 status 与 commit 命令的补充
本文的"剧情"承接 [Git] 007 三棵树以及向本地仓库加入第一个文件 1. 对 "status" 的补充 1.1 "status" 有 ...
- 从code review到Git commit log
最近在读一本技术类的书:朱赟——<跃迁:从技术到管理的硅谷路径>,其中聊了很多很有趣的观点,比如:技术管理.技术实践.硅谷文化.个人成长等. 读到关于硅谷人如何做code review这一 ...
- git 撤销add和commit
有时候改完代码发现改错分支了,而这个时候已经add或者commit了,怎么办,有办法: 1.若果已经add . 了这个时候可以使用git stash命令,具体操作命令如下: (1) > git ...
- git —— 基本命令以及操作(No.1)
git基本命令(附加描述) 1.把文件添加到暂存区$ git add readme.txt 2.把暂存区的文件文件添加到仓库$ git commit -m "提交说明" 备注:ad ...
- git基本命令和仓库操作
首先git是什么?git是github上的一个代码托管工具,是一款代码版本管理工具,github上的代码是基于git来进行托管的.github是全球的开源社区.Git 保存的不是文件的变化或者差异,而 ...
- Git基本命令行操作 (转)
Git远程操作详解 作者: 阮一峰 Git是目前最流行的版本管理系统,学会Git几乎成了开发者的必备技能. Git有很多优势,其中之一就是远程操作非常简便.本文详细介绍5个Git命令,它们的概念和 ...
随机推荐
- windows和Ubuntu双系统的安装和基本操作
因为最近刚开始学习ubuntu系统,首先要安装系统,搜集了网上的资料觉得这篇博客特别有用 http://www.cnblogs.com/Duane/p/5424218.html,我也是按照里面的步骤 ...
- Hive中频繁报警的问题
在使用Hive的过程中,是不是会在shell中报一堆警告,虽然说不影响正常使用,但是看着很烦人,而且指不定会影响数据的准确性和运行的稳定性. 警告的内容如下: Tue Aug :: CST WARN: ...
- Chapter 2 Open Book——30
I looked down. His hands were clenched into hard fists again. 我向下看,他的双手又一次收紧握成拳头. Mr. Banner came to ...
- Ubuntu安装Mysql过程及远程问题解决
ubuntu下执行 sudo apt-get instlll mysql-server sudo apt-get install mysql-client 安装过程中会有文字界面设置密码 牢记密码 M ...
- BitSort
这个题为<编程珠玑>中提到的算法,解题思路和桶排序/基数排序一样,适用于大量没有重复的数据. 结题思路: 1.遍历整个数据文件,每提取一个数据,在BitMap中对应的位置赋1 2.遍历Bi ...
- 支付顺序-->微信支付到公司账户-->待出票
支付顺序-->微信支付到公司账户-->待出票-->查询所有待出票订单 -->遍历提交订单-->火车票接口放回订单id-->存入order订单表中 -->读取订 ...
- C#获取数字证书
string Thumbprint = "C2489D912F247C187AA14B1291A6fB612281225D"; X509Store store = new X509 ...
- php字符操作
//一:定义字符串的方法 //1.双引号 //2.单引号 //3.heredoc语法结构 //heredoc语法定义字符串 $str=<<<TAG 我的武功终成武林盟主TAG;//注 ...
- Linux RCU机制详解
关于rcu的几点声明: 1:RCU使用在读者多而写者少的情况.RCU和读写锁相似.但RCU的读者占锁没有任何的系统开销.写者与写写者之间必须要保持同步,且写者必须要等它之前的读者全部都退出之后才能释放 ...
- .Net_用控制台程序打印指定行数的三角型(面试题)
.Net_用控制台程序打印指定行数的三角型(面试题) 下面是一个由*号组成的4行倒三角形图案.要求: 1.输入倒三角形的行数,行数的取值3-21之间,对于非法的行数,要求抛出提示“非法行数!”: ...