I would like to know how to use git blame to know who created a single directory.
When I try:
git blame DIRECTORY_NAME
I get:
I created a small function what loops over all files and makes a directory blame view similar to GitHub.
Output format is:
FILENAME COMMIT-HASH Commit-DATE AUTHOR COMMIT-MESSAGE
looks like this
myfile1 abceeee 2019-04-23 19:26 Radon8472 Added file example
readme.md abd0000 2019-04-24 19:30 Radon8472 Update Readme-File
blamedir()
{
FILE_W=35;
BLAME_FORMAT="%C(auto) %h %ad %C(dim white)%an %C(auto)%s";
for f in $1*;
do
git log -n 1 --pretty=format:"$(printf "%-*s" $FILE_W "$f") $BLAME_FORMAT" -- $f;
done;
};
usage-eamples:
blamedir
similar like blamedir ./
blamedir DIRECTORY_NAME/
Feel free to change the display format by changing the Variable BLAME_FORMAT
in the function.
I think it should be possible to set this function as git-alias too.