Making git report to get commits

Here is a quick tip, I’ve to create a report in my work to know how many commits we’ve into a certain period by repository and person (commiter) and show in excel with a chart.

I can’t download the data from our git server because the rest API is disabled, then we’ve to do it manually and I’ve created an script(bat file) to extract the data, but is needed execute per repository.


@echo off
SETLOCAL
for %%f in (%CD%) do set dirname=%%~nxf
set dir_name="%dirname%"
set "TAB= "
git fetch
git log --pretty=format:"%dir_name%%TAB%%%C(yellow)%%h%TAB%%%C(cyan)%%ci%TAB%%%cn" --since="2020-01-01 00:00:00" --before="2020-06-31 23:59:59"
echo .

This can be executed outside of the each repository and aggregate the results in a text file:


cd C:\repositories\repo1

"C:\scripts\getCommits.bat" >> "C:\Users\jaehoo\Desktop\out.txt"

cd C:\repositories\repo2

"C:\scripts\getCommits.bat" >> "C:\Users\jaehoo\Desktop\out.txt"

The result is separated by tab spaces and it could be read in excel:

2020-05-14 09_51_33-Libro3 - Excel

And the pivot table can help to count and show the data.

2020-05-14 09_53_37-Libro3 - Excel

I leave here some variances of the command, may be It could be usefully:


git log --pretty=format:"%C(yellow)%h %C(cyan)%ci %cn" --since="2020-01-01 00:00:00" --before="2020-06-31 23:59:59"

git log --graph --pretty=format:"%cn %m %cs %C(yellow)%h%x09%Creset%C(cyan)%C(bold)%ad%Creset %C(green)%Creset %s" --date=short

git log --pretty=format:"%C(yellow)%h %C(cyan)%ci %cn" ^
--since="2020-01-01 00:00:00" ^
--before="2020-06-31 23:59:59" ^
--author="jaehoo"

git shortlog --since="2020-01-01 00:00:00" --before="2020-06-31 23:59:59" --summary --numbered --email

Saludos

References

https://mirrors.edge.kernel.org/pub/software/scm/git/docs/git-log.html#_pretty_formats

Source Tree resolve conflicts with an external tool

2018-05-21 12_55_29-Sourcetree-blue - Internet Explorer

Source Tree supports multiple external tools to compare differences and resolve conflicts between files. By default you can choose any of this:

Source tree tools

But In this entry I’m going to show how to use it with Meld. 

Meld is a visual diff and merge tool targeted at developers. Meld helps you compare files, directories, and version controlled projects.

In linux systems it’s very useful and it’s my preffered tool (only when I can’t use diff and merge tools from my IDE).

How to configure

For Windows

Go to main menu and select Tools > Options > Diff tab, into selection option External Diff  pick Custom and into field Diff Command set the path to your meld binary (on windows is Meld.exe),  into field Arguments set this:

\"$LOCAL\" \"$REMOTE\"

Now for Merge Tool, select the same binary (Meld.exe) and set this into filed Arguments:

--auto-merge \"$LOCAL\" \"$BASE\" \"$REMOTE\" --output=\"$MERGED\"

Now, if you choose any file in your project you can check the diff selecting External Diff or with shorcut CTRL+D over your file, and meld it’s executed:

extdifmeld

And it’s the same for files in conflict, select your file with the context menu Resolve conflicts > Launch External Merge Tool, now you can view side to side the differences between versions.

extmergemeld

For Mac OSX

Meld is available for OSX here, download and install it.

Select Sourcetree menu > Preferences > Diff tab, on Diff command and Merge command set this value:

open -W -a Meld

For Diff command set  this args:

 --args  $LOCAL $REMOTE

For  Merge command set  this:

--args --auto-merge $LOCAL $BASE $REMOTE --output=$MERGED

Note:If you want to disable auto backup files (with .orig extension) from git execute this command:

 git config --global mergetool.keepBackup false

And thats all, cheers

References