如何让'git diff'只显示提交消息

Lou*_*ost 8 git

如何使用git diff仅显示提交消息?

我只想要提交的消息,而不是文件的名称。我正在尝试在 Git 中获取更改日志。

Ant*_*lko 8

除了西蒙·克莱尔的回答之外:

git log master..dev --no-merges --pretty='format:%cs %s'
Run Code Online (Sandbox Code Playgroud)

它仅打印主分支和开发分支之间的提交主题(没有合并提交)。像这样的东西:

2020-12-31 Hot fix
2020-12-30 Change some stuff
2020-12-29 Add the feature
Run Code Online (Sandbox Code Playgroud)

本地和远程分支之间的变化:

git log HEAD..origin --no-merges --pretty='format:%cs %s'
Run Code Online (Sandbox Code Playgroud)

另请参阅使用 Git 管理变更日志有哪些好方法?


Sim*_*wer 7

你可以尝试git log,因此,

git log commitA...commitB
Run Code Online (Sandbox Code Playgroud)

三点符号 '...' 只为您提供可从 commitA 或 commitB 访问的所有提交的提交消息,但不能同时从两者访问 - 即 commitA 和 commitB 之间的差异。

您可以使用以下内容轻松地将提交消息精简为:

git log --pretty=%B commitA...commitB
Run Code Online (Sandbox Code Playgroud)

一些例子

# Show a log of all commits in either the development branch or master branch since they diverged.
git log --pretty=%B development...master
Run Code Online (Sandbox Code Playgroud)
# Ahow a log of all commits made to either commit b8c9577  or commit 92b15da, but not to both.
git log --pretty=%B b8c9577...92b15da
Run Code Online (Sandbox Code Playgroud)
# Show a log for all commits unique to either the local branch master or local version of the origin's master branch.
git co master
git log --pretty=%B master...origin/master
Run Code Online (Sandbox Code Playgroud)
# Show a log for all commits unique to either the local HEAD or local version of the origin's master branch.
git co master
# Hack, hack
git log --pretty=%B HEAD...origin/master
Run Code Online (Sandbox Code Playgroud)


Cod*_*ard 5

用:

git log --oneline -n 10
Run Code Online (Sandbox Code Playgroud)

它将在单行上打印出最后n (10) 次提交。只是提交消息。

您还可以将其与其他日志参数结合使用,例如:

git log --oneline --graph --decorate -n 10
Run Code Online (Sandbox Code Playgroud)