Good morning, I need to export the git log into a CSV or Excel file, including the comments of the commits.
I found this post that gave me some ideas: Export GIT LOG into an Excel file
However I have two additional requirement for which I haven't found help so far.
Of course, if I can fulfill the point 2), I am open to use any delimiter character. Could somebody please give an example of git log bash command?
After some test I could find the solution. I have used a git bash script.
echo "hash;user;date;comment" > gitlog.csv
git log origin/master --date=local --pretty="%h%x3B%an%x3B%ad%x3BCOMMENTMARK%BCOMMENTMARK" | tr '"' "'" >> gitlog.csv
sed -i 's/COMMENTMARK/\"/g' gitlog.csv
One can change "origin/master" in something else if needed. Explanation:
I had to split the escaping of the double quotes in two steps, because the GIT cannot escape characters in comments.
Having wrapped the comments in double quotes allows the presence of new line characters inside the comments.
I hope it can be useful for the community.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.