Skip to content

Instantly share code, notes, and snippets.

@asdf8601
Forked from mrts/index.html
Last active June 12, 2021 11:17
Show Gist options
  • Save asdf8601/c092d99095220acde1adca8b7b78bdfb to your computer and use it in GitHub Desktop.
Save asdf8601/c092d99095220acde1adca8b7b78bdfb to your computer and use it in GitHub Desktop.
Example of Gitgraph.js usage
<!DOCTYPE html>
<html>
<head>
<!-- Load the JS file -->
<script src="https://cdn.jsdelivr.net/npm/@gitgraph/js"></script>
</head>
<body>
<!-- DOM element in which we'll mount our graph -->
<div id="graph-container"></div>
<!-- Use the `GitgraphJS` global variable to create your graph -->
<script>
// Get the graph container HTML element.
const graphContainer = document.getElementById("graph-container");
// Instantiate the graph.
const gitgraph = GitgraphJS.createGitgraph(graphContainer);
// Simulate git commands with Gitgraph API.
const master = gitgraph.branch("master");
master.commit("Initial commit");
const develop = master.branch("develop");
develop.commit("Add TypeScript");
const aFeature = develop.branch("a-feature");
aFeature
.commit("Make it work")
.commit("Make it right")
.commit("Make it fast");
develop.merge(aFeature);
develop.commit("Prepare v1");
master.merge(develop).tag("v1.0.0");
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment