Gource Guide: Turn Git Commit History into Stunning Video Animations

Git tutorial - IT technology blog
Git tutorial - IT technology blog

Why Visualize Git History?

Who says git log has to be boring black and white text? Truth be told, those dry command lines are usually only interesting to us techies. When you need to report progress to clients or showcase work at a Year-end Party, a vivid video animation is far more persuasive than any static chart.

Gource is an open-source tool that turns your commit history into a living ecosystem. Directories act as branches, files as leaves, and team members as entities moving around to build or modify the source code. Watching the video, you can clearly see the code explosion during crunch times or large-scale refactors involving thousands of file changes.

I once worked on an 18-month outsourcing project with over 5,000 commits. The client wondered why progress seemed slow in the early stages. Instead of a technical explanation, I used Gource to replay the team tearing down and rebuilding the entire core engine. Seeing hundreds of old files deleted and replaced by a clean new structure, the client immediately understood the team’s effort.

Quick Gource Installation

Gource supports most popular platforms. Installation takes just a few seconds through package managers.

For macOS

Using Homebrew is the fastest way:

brew install gource

For Linux (Ubuntu/Debian)

sudo apt-get install gource

For Windows

You can download the .exe directly from Gource’s GitHub or use Chocolatey for a more professional approach:

choco install gource

Getting Started with Basic Commands

To run Gource, open your terminal, navigate to the root directory of your Git project, and type:

gource

Immediately, a window will appear playing the commit history from day one. However, the default configuration often has low resolution, and the playback speed might be too fast or too slow depending on the project’s scale.

Here is the set of parameters I usually use to make the video look more professional:

gource -1280x720 --seconds-per-day 1 --auto-skip-seconds 1 --title "Fintech Project 2024"
  • -1280x720: Sets a standard HD resolution.
  • --seconds-per-day 1: Compresses one workday into 1 second of video.
  • --auto-skip-seconds 1: Automatically skips days with no commits.
  • --title: Displays the project name in the corner for branding.

Customizing for a High-Quality Video

A raw Gource video can be quite cluttered if the project contains many junk files. Apply these 3 tips to keep the video focused on the core components.

1. Filtering Out “Noise” Directories

Don’t let thousands of files in node_modules or vendor dilute the video. Use regex to exclude them:

gource --hide filenames,dirnames --ignore-dir "node_modules|vendor|.git"

2. Personalizing Member Avatars

By default, Gource displays generic person icons. To see who is “smashing” the code, connect to Gravatar or use local images. Note: the image filename must match the Git username.

gource --user-image-dir path/to/avatars/

3. Grouping Authors (Mailmap)

A developer might commit using both work and personal emails. This leads Gource to mistake them for two different people. Create a .mailmap file in the root directory to merge these identities:

Official Name <[email protected]> Old Name <[email protected]>

How to Export Gource to Video Format (MP4)

Gource doesn’t have a direct “Save Video” button. We need to pipe the data to ffmpeg to package it into an MP4 file. This is the technique I use to create clips for the marketing team.

First, install ffmpeg. Then run the following data pipe command:

gource -1920x1080 -o - | ffmpeg -y -r 60 -f image2pipe -vcodec ppm -i - -vcodec libx264 -preset ultrafast -pix_fmt yuv420p -crf 18 -threads 0 project_history.mp4

Breaking down this command:

  • -o -: Exports raw images to the standard output stream (stdout).
  • -r 60: Forces the frame rate to 60fps for smoothness.
  • -vcodec libx264: Uses the H.264 compression standard, which is widely used today.
  • -crf 18: Maintains high video quality (lower numbers mean sharper video).

Real-world Implementation Experience

For large projects spanning several years, the video can be over an hour long. My advice is to focus only on important milestones. You can limit the time frame using the --start-date and --stop-date parameters.

gource --start-date "2023-01-01" --stop-date "2023-12-31"

Additionally, Gource helps spot anomalies in the workflow. If you see a code region only touched by a single person over a long period, it’s a sign of a lack of knowledge sharing. If that person goes on leave, that code becomes a dangerous “blind spot” for the team.

Conclusion

Gource is more than just a “showy” tool. It breathes life into a project’s history, helping the team look back on their journey in an inspiring way. Try running it on your current project. You’ll surely be surprised to see your hard work come to life as a piece of art.

Share: