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

Commit history on remote repository

git log remotename/branchname Will display the log of a given remote branch in that repository, but only the logs that you have “fetched” from their repository to your personal “copy” of the remote repository. Remember that your clone of the repository will update its state of any remote branches only by doing git fetch. You … Read more