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命令,它们的概念和 ...
随机推荐
- bayboy下载安装
badboy是jmeter工具的好搭档. 好处体现在那里呢? JMeter是纯Java编写的软件功能和性.能测试工具,其录制脚本过于笨拙和复杂. 而Badboy是用C++开发的动态应用测试工具,其拥有 ...
- C# lesson1
一.C#和.net平台 .net是一个软件,一个平台(一般在windows自带 或者在vs里面已经有了) C#是一门运行在.net平台上的语言,需要编译:C#经过.net framework里面的编译 ...
- php 5.5 xhprof for windows
今天看到一个好的性能优软件xhprof(有facebook开发的类库)在国内找了很多网站都没有找到相关php5.5的扩展,只好FQ还是外面的世界精彩一下就找到了link (http://windows ...
- 部分服务器使用phpExcel会报错
其中一个错误提示是:Fatal error: 'break' not in the 'loop' or 'switch' context in /var/www/htdocs/hanya/ThinkP ...
- android 5.0 -- 主题
系统提供默认的三种主题样式 @android:style/Theme.Material (dark version) @android:style/Theme.Material.Light (ligh ...
- 通用mapper的使用
通用mapper的使用 导入依赖 <dependency> <groupId>com.github.abel533</groupId> <artifactId ...
- CodeForces 699A Launch of Collider
枚举相邻两个$a[i]$与$a[i+1]$,如果$s[i]=R$并且$s[i+1]=L$,那么$i$和$i+1$会碰撞,更新答案. #pragma comment(linker, "/STA ...
- Cells(Rows.Count, 1).End(xlUp).Row的含义
NextRow = ActiveSheet.Cells(Rows.Count, 1).End(xlUp).Row + 1 这句话的意思是 取活动单元表的第一列最后一个有值的行的下一行行号. ...
- Spring Security(02)——关于登录
目录 1.1 form-login元素介绍 1.1.1 使用自定义登录页面 1.1.2 指定登录后的页面 1.1.3 指定登录失败后的页面 1.2 http-basi ...
- 针对IE的CSS样式hack
针对IE的CSS样式hack,如下: 例子:background:#000: 1.只针对IE6的hack方式(_):_background:#000: 2.只针对IE7的hack方式(+):+back ...