Git

Pretty Git Branch Graphs

Git provides several commands with the most fantastic features to perform different operations on the local repository. More specifically, the graph feature is one of the prettiest features of the “$ git log” command. This command generates a graphical overview of how the multiple development pipelines of the user are branched and merged over time.

This guide will explain how to generate pretty graphs for Git local branches.

How to Generate Pretty Git Branch Graphs?

Multiple commands are used to create a pretty graph in different scenarios, such as to view the graph for the desired local branch, including the time, without mentioning the time or textual representation of the graph of the required local branch. For this purpose, the “$ git log” command can be utilized to create pretty Git branch graphs along with different parameters, their value, and option.

Let’s move forward and execute the above-listed command to generate several pretty graphs!

Step 1: Navigate to Particular Git Repository

Utilize the below-stated command to move to the Git local repository:

$ cd "C:\Users\nazma\Git\demo11"

Step 2: Show Pretty Branch Graph Including Time

Now, run the below-listed command to view the pretty graph of the branch including with date, day, time, and commit message:

$ git log --graph --abbrev-commit --decorate --format=format:'%C(bold blue)%h%C(reset) - %C(bold cyan)%aD%C(reset) %C(bold green)(%ar)%C(reset)%C(bold yellow)%d%C(reset)%n''     %C(white)%s%C(reset) %C(dim white)- %an%C(reset)' --all

Step 3: Show Pretty Branch Graph Without Mentioning Time

To display the pretty graph with details excluding exact date, day, and time, run this command:

$ git log --graph --abbrev-commit --decorate --date=relative --format=format:'%C(bold blue)%h%C(reset) - %C(bold green)(%ar)%C(reset) %C(white)%s%C(reset) %C(dim white)- %an%C(reset)%C(bold yellow)%d%C(reset)' --all

Step 4: Show Textual Graph Representation

Run the “git log –graph” command along with the “–oneline –all” parameter to view the textual output of the Git branch graph:

$ git log --graph --oneline --all

That’s it! We have provided the easiest way to view the pretty Git branch graphs.

Conclusion

Multiple commands are used to create a pretty graph of the Git particular branch, such as the “$ git log” command can be utilized to create pretty Git branch graphs along with different parameters, their value, and option. It permits you to view the pretty graph for the desired local branch, including the time, without mentioning the time or textual representation of the pretty graph of the required local branch. This guide demonstrated how to generate pretty graphs for Git local branches.

About the author

Maria Naz

I hold a master's degree in computer science. I am passionate about my work, exploring new technologies, learning programming languages, and I love to share my knowledge with the world.