How to see commits that were merged in to a merge commit?

git log abc123^..abc123 shows the commits that got merged into merge-commit abc123. Create a git alias log-merge for easy reuse: $ git config –global alias.log-merge \ ‘!f() { git log –stat “$1^..$1”; }; f’ $ git log-merge abc123 For a one-line version: $ git config –global alias.log-merge-short \ ‘!f() { git log –pretty=oneline “$1^..$1”; }; … Read more

How to search a Git repository by commit message?

To search the commit log (across all branches) for the given text: git log –all –grep=’Build 0051′ To search the actual content of commits through a repo’s history, use: git grep ‘Build 0051’ $(git rev-list –all) to show all instances of the given text, the containing file name, and the commit sha1. Finally, as a … Read more

How can I view file history in Git?

Use git log to view the commit history. Each commit has an associated revision specifier that is a hash key (e.g. 14b8d0982044b0c49f7a855e396206ee65c0e787 and b410ad4619d296f9d37f0db3d0ff5b9066838b39). To view the difference between two different commits, use git diff with the first few characters of the revision specifiers of both commits, like so: # diff between commits 14b8… and … Read more

How to find the commit in which a given file was added?

Here’s simpler, “pure Git” way to do it, with no pipeline needed: git log –diff-filter=A — foo.js Check the documentation. You can do the same thing for Deleted, Modified, etc. https://git-scm.com/docs/git-log#Documentation/git-log.txt—diff-filterACDMRTUXB82308203 I have a handy alias for this, because I always forget it: git config –global alias.whatadded ‘log –diff-filter=A’ This makes it as simple as: … Read more