先进入此文件所在的目录下
1. git log --help
所有的git命令都可以通过git manual查看
在synopsis中可以看到公式 git log [<options>] [[--] <path>] 其中 []中的内容可以为空
每个option都有相应的解释
git log --help
GIT-LOG(1) Git Manual GIT-LOG(1)
NAME
git-log - Show commit logs
SYNOPSIS
git log [<options>] [<revision range>] [[--] <path>...]
DESCRIPTION
Shows the commit logs.
The command takes options applicable to the git rev-list command to control what is shown
and how, and options applicable to the git diff-* commands to control how the changes each commit introduces are
shown.
OPTIONS
--follow
Continue listing the history of a file beyond renames (works only for a single file).
--no-decorate, --decorate[=short|full|no]
Print out the ref names of any commits that are shown. If short is specified, the ref name
prefixes refs/heads/, refs/tags/
and refs/remotes/ will not be printed. If full is specified, the full ref name (including prefix) will
be printed. The default option is short.
:
2. git log -- filename (git log filename)
可以看到该文件相关的commit记录
git log -- README.md
commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d
Author: lin <542072149@qq.com>
Date: Fri Jun 2 10:47:11 2017 +0800
测试
Change-
Id: Ifbbb04e664407bb89f726bf967d2847ed211a949
commit 999e31080f96c29d84e11a82e87bfa175976fe0e
Author: lin <542072149@qq.com>
Date: Fri Apr 21 10:13:19 2017 +0800
测试
Change-
Id: Iafb710f80d7970d052a0298ece955ce1fc3840ed
commit 0eaa6ba18abde83622379f152d42f63754a6fd5c
Author: lin <542072149@qq.com>
Date: Fri Apr 21 10:12:28 2017 +080
3. git log -p filename
可以显示该文件每次提交的diff
git log -p README.md
commit 83bb011fac7cd4b94c7e711fc1b4457c43b0e60d
Author: lin <542072149@qq.com>
Date: Fri Jun 2 10:47:11 2017 +0800
测试
Change-
Id: Ifbbb04e664407bb89f726bf967d2847ed211a949
diff --git a/README.md b/README.md
index 565897b..85c6bcf
100644
--- a/README.md
+++ b/README.md
@@ -
5,8 +5,9 @@ add a line ss
新加一行, 完善一下
for ticket
11
-
+UUU
home
test
and 11
+
2017-06-02 10:46
4. git show commit-id filename
查看某次提交中的某个文件变化
git show 999e31080f96c29d84e11a82e87bfa175976fe0e README.md
commit 999e31080f96c29d84e11a82e87bfa175976fe0e
Author: lin <542072149@qq.com>
Date: Fri Apr 21 10:13:19 2017 +0800
测试
Change-
Id: Iafb710f80d7970d052a0298ece955ce1fc3840ed
diff --git a/README.md b/README.md
index 8b79f6f..565897b
100644
--- a/README.md
+++ b/README.md
@@ -
2,7 +2,7 @@Add a little content Srebase i
add a line
-
+ss
新加一行, 完善一下
for ticket
11
(END)
5.git show commit-id
根据commit-id查看某个提交
6.借助可视化工具 如 sourceTree 在最后一次修改的记录上 右键选中文件 查看历史修改
7.git log 的常用选项
选项说明 -p
按补丁格式显示每个更新之间的差异。
--stat
显示每次更新的文件修改统计信息。
--shortstat
只显示 --stat 中最后的行数修改添加移除统计。
--name-only
仅在提交信息后显示已修改的文件清单。
--name-status
显示新增、修改、删除的文件清单。
--abbrev-commit
仅显示 SHA-1 的前几个字符,而非所有的 40 个字符。
--relative-date
使用较短的相对时间显示(比如,“2 weeks ago”)。
--graph
显示 ASCII 图形表示的分支合并历史。
--pretty
使用其他格式显示历史提交信息。可用的选项包括 oneline,short,full,fuller 和 format(后跟指定格式)。
选项说明 -(n)
仅显示最近的 n 条提交
--since, --after
仅显示指定时间之后的提交。
--until, --before
仅显示指定时间之前的提交。
--author
仅显示指定作者相关的提交。
--committer
仅显示指定提交者相关的提交。
--grep
仅显示含指定关键字的提交
-S
仅显示添加或移除了某个关键字的提交
运维网声明
1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网 享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com