Sri
Sri

Reputation: 103

Use gitgraph for existing git project

I want to view my commits on git project graphically, so I downloaded the GitGraph.js package from gitgraphjs.com.

How can I view my repository graphically using GitGraph.js?

Upvotes: 3

Views: 1011

Answers (3)

Code-Apprentice
Code-Apprentice

Reputation: 83577

I suggest using git log --oneline --graph --all. This is a very good visualization tool that comes with the git CLI.

Upvotes: 0

publicdomain
publicdomain

Reputation: 1742

I currently am working on a private repository server, on which I implemented this functionality.

As I didn't open-source that project yet, I created a github repository real-gitgraph containing the core functionality. It is written in php and uses git log to get commit and tag information.


All you have to do is include the real-gitgraph.php file and gitgraph.js:

<!-- include the tool / library -->
<?php include 'real-gitgraph.php'; ?>

<!-- include gitgraph.js -->
<script type="text/javascript" src="https://cdn.jsdelivr.net/npm/@gitgraph/js"></script>

If you want to display the graph for a repository located at $repoDirectory, this is what you do:

<!-- Draw the GitGraph -->
<div id="graph-container"></div>
<script><?php echo gitGraphJS($repoDirectory); ?></script>

GitHub: finnmglas/real-gitgraph


There still are some issues with this repository, currently (2020-07-17) it can:

  • Graph all commits on the master branch
  • Show commit messages and hashes (as tooltips for horizontal graphs)
  • Display version tags (see screenshot below)

An example git-graph, generated using the included example.php script:

an example graph

(Note: you can easily customize the graphs design using the template in real-gitgraph.php)


It took me quite a while to get all this set up, if you want to, feel free to contribute ^^

Upvotes: 0

Francesco
Francesco

Reputation: 4250

Gitgraph.js is a simple JavaScript library which is meant to help you visually presenting git branching stuff like a git workflow, a tricky git command or whatever git tree you'd have in mind.

Which means you cannot use gitgraph to represent an actual repository. It is used just to explain git concepts.

You can try sourcetree or other git gui programs.

Upvotes: 3

Related Questions