AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Github see commit history12/13/2023 ![]() ![]() The ‘ git shortlog‘ command categorizes the commit logs author wise and prints an overview summary, indicating the commits made by each author. Bonus: Summarise git log output: ‘git shortlog’ This is a useful command, to indicate a barrier between 2 consecutive commits that do not belong to a linear branch, in other words the commits that came from different branches.Ĭompare the above output with the ‘git log –graph’ command output that clearly shows how the “linear-break” commits have been merged. This lets you understand when, how and why and other branches were merged into the currently checked out branch. Improved oneliner output: git log -graph -oneline 1.8 –graphĭraw a text-based graphical representation of the commit history before the sha-1 ids. The next change you make and commit on this branch will be the child commit object of this latest sha-1 id. 1.7 –childrenĠ06b9ce is the latest commit, hence has no children commit object yet. Whereas, 86792c6 is the initial commit, hence no parent. Oneliner output Command: git log -parents -onelineĬ366419 is a merge commit, hence has 2 parents respectively: feeb30c and 4920adcġd67b50 is a merge commit, that resulted from merging f2ff2e4 and abb694bĠ78f9f5 is a merge commit created by merging 9a2412e and ab3a5e5 Print also the parents of each commit in the format: ![]() Print the time as seconds since the unix epoc time ( ) followed by the timezone. 1.5.2 –date=localġ.5.7 –date=raw (shows the date in seconds) This is synonymous with the above command “ git log -relative-date” and prints the same commits. You can also format the commit logs date in any of the following format options: 1.5.1 –date=relative Kindly note, this highlighted time is subjected to change with reference to the time you execute the command on your system. This negates –abbrev-commit and those options which imply it such as “–oneline”.Ĭommand: git log -pretty=oneline -no-abbrev-commit Show the full 40-byte hexadecimal commit object name. ![]() What’s more exciting is that you can also specify the byte length of sha-1 ids using the ‘–abbrev=’ option, as shown below:Ĭommand: git log -abbrev-commit -abbrev=5 -onelineĬlearly, the highlighted sha-1 ids are reduced to 5-byte size. Let us club it with the ‘ -oneline‘ option for a convenient view, like so:Ĭommand: git log -abbrev-commit -oneline The full 40-byte hexadecimal commit object name is shortened to default 7-bytes. Now, to check the history of the current branch all you have to do is run the command, like so:ġ.2 –abbrev-commit: Shorten git commit hash-id So, as you would have observed I am setting my global git configuration file with the values. Git config -global alias.c-hist 'log -pretty=format:"%C(yellow)%h%Creset %ad | %Cgreen%s%Creset %Cred%d%Creset %Cblue" -date=short' You do not have to remember and write the whole command every time, just use a short name as git alias as shown below: %Cblue: Make the author name blue in color %Cred: Change the following string to red %Cgreen: change following string to green %Creset: Reset the following string back to default(white) color %C(yellow): Turn the following string to yellow Some other placeholders used in the above code snippet are: Git log -pretty=format:"%C(yellow)%h%Creset %ad | %Cgreen%s%Creset %Cred%d%Creset %Cblue" -date=short Now, how about making this output more human-friendly, using colors. –date=short: Print just the date and not time in a readable format Let us consider the various placeholder this option provides just like a ‘C printf’ function with the help of code snippets:Ĭommand: git log -pretty=format:"%h %ad | %s %d " -date=short The format allows you to specify which information of the commit object you want to print in the commit output log The raw log output format shows the entire commit exactly as stored in the commit object. Print log output in the email style format: Print commit output in the ‘medium’ format: Pretty print commit log in a ‘single line’įormat commit output ‘short’ in the format: When = part is omitted, it defaults to medium. Where, can be one of oneline, short, medium, full, fuller, email, raw, and format: Commit Formatting 1.1 Pretty-print the output contents in a given format $ git checkout feature1–jump to the ‘feature1’ branch 1. Since we already know, Git keeps a Journal of the changes committed to the project history, we shall now explore more ways the ‘git log’ command is helpful.įirstly, I am switching-to/checking out the “feature1” branch for a convenient and shorter history. In this article, we will discuss some advanced options to format and print the commit logs to fetch the information that you need out of your project journal history. ![]()
0 Comments
Read More
Leave a Reply. |