Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get 'git diff' to only show commit messages

Tags:

git

How do I use git diff to only show commit messages?

I just want the message of the commit, not the name of the files. I am trying to get a change log in Git.

like image 787
Chris Hansen Avatar asked Nov 10 '15 22:11

Chris Hansen


People also ask

How can I see commit in diff?

To see the changes between two commits, you can use git diff ID1.. ID2 , where ID1 and ID2 identify the two commits you're interested in, and the connector .. is a pair of dots. For example, git diff abc123.. def456 shows the differences between the commits abc123 and def456 , while git diff HEAD~1..

How do I see all commit messages?

Viewing a list of the latest commits. If you want to see what's happened recently in your project, you can use git log . This command will output a list of the latest commits in chronological order, with the latest commit first.

Does git diff show all changes?

The git diff command returns a list of all the changes in all the files between our last commit and our current repository. If you want to retrieve the changes made to a specific file in a repository, you can specify that file as a third parameter.

Why git diff does not show changes?

Your file is already staged to be committed. You can show it's diff using the --cached option of git. To unstage it, just do what git status suggests in it's output ;) You can check The Git Index For more info.


2 Answers

You could try git log, thus,

git log commitA...commitB

The triple dot notation '...' gives you just the commit messages for all the commits that are reachable from commitA or commitB, but not from both - i.e., the diff between commitA and commitB.

You can easily strip down to just the commit message with something like:

git log --pretty=%B commitA...commitB

Some examples

# Show a log of all commits in either the development branch or master branch since they diverged.
git log --pretty=%B development...master
# Ahow a log of all commits made to either commit b8c9577  or commit 92b15da, but not to both.
git log --pretty=%B b8c9577...92b15da
# 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
# 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
like image 115
Simon Clewer Avatar answered Oct 20 '22 10:10

Simon Clewer


Use:

git log --oneline -n 10

It will print out the last n (10) commits on single lines. Just the commit messages.

You can also combine it with other log parameters, like:

git log --oneline --graph --decorate -n 10
like image 31
CodeWizard Avatar answered Oct 20 '22 10:10

CodeWizard