Skip to content

gitk Git Command Guide

The gitk command is The Git repository browser that displays changes in a repository or selected commits, including visualizing the commit graph, showing commit-related information, and browsing files at each revision.

Terminal window
gitk [<options>] [<revision-range>] [--] [<path>...]
OptionDescription
—allShow all refs (branches, tags, remotes)
—branches[=]Show branches matching pattern
—tags[=]Show tags matching pattern
—remotes[=]Show remotes matching pattern
—since=Show commits more recent than date
—until=Show commits older than date
—author=Show commits by authors matching pattern
—committer=Show commits by committers matching pattern
—grep=Show commits with messages matching pattern
—max-count=Limit number of commits shown
—mergesShow only merge commits
—no-mergesDon’t show merge commits
—first-parentFollow only first parent in merges
—onelineCondensed commit display
ParameterDescription
Commits to display (e.g., master..develop)
Restrict to commits touching specified paths
Terminal window
gitk --all

Shows all branches, tags, and remotes in the repository history graph.

Terminal window
gitk master..feature-branch

Visualizes commits that exist in feature-branch but not in master.

Terminal window
gitk --since="2 weeks ago" --author="John Doe"

Displays commits by John Doe made in the last 2 weeks.

Terminal window
gitk -- src/main.c

Shows history of changes to main.c file only.

Terminal window
gitk --merges --since="1 month ago"

Displays only merge commits from the past month.

Terminal window
gitk --first-parent master

Shows linear history along master branch, ignoring merge commits.

Terminal window
gitk --grep="fix.*memory leak"

Finds commits with messages containing “fix” followed by “memory leak”.

Terminal window
gitk --tags

Shows all tagged commits in chronological order.

Terminal window
gitk --max-count=50 --all

shows the most recent 50 commits across all branches.

Terminal window
gitk --author="Alice\|Bob" --since="2024-01-01"

Displays commits by either Alice or Bob since New Year.

gitk renders the commit Directed Acyclic Graph (DAG) as a visual tree where each commit node shows parent relationships. Lines connect children to parents, diverging for branches and converging at merges.

What’s the difference between gitk and git log —graph?

Section titled “What’s the difference between gitk and git log —graph?”

While git log --graph shows text-based graph representation in terminal, gitk provides interactive GUI with clickable commits, expandable diffs, and file browsing capabilities.

gitk cannot display diffs for binary files directly but can show that a binary file changed and list its basic information. Use git diff command line for detailed binary file analysis.

gitk doesn’t have built-in view saving, but you can create shell aliases or scripts that invoke gitk with specific option combinations for recurring analyses.

Does gitk support Git LFS (Large File Storage)?

Section titled “Does gitk support Git LFS (Large File Storage)?”

gitk can show LFS file commits and basic information but cannot display actual large file contents. LFS integration shows file status but delegates actual content viewing to external tools.

No, gitk is strictly a repository browser for visualization and exploration. For creating or modifying commits, use git gui or command-line Git tools.

What’s the performance impact of loading large repositories in gitk?

Section titled “What’s the performance impact of loading large repositories in gitk?”

gitk loads entire commit history into memory, so performance degrades with large repositories (>10,000 commits). Use --max-count or narrowed revision ranges to improve responsiveness.

gitk supports limited color customization through X11 resources or command-line options, but color schemes are more limited compared to modern GUI tools.

Can gitk handle repository with multiple remote tracking branches?

Section titled “Can gitk handle repository with multiple remote tracking branches?”

Yes, gitk shows all refs including remote-tracking branches. Use —remotes option to focus specifically on remote references, or —all to include everything.

What’s the relationship between gitk and git gui?

Section titled “What’s the relationship between gitk and git gui?”

While gitk focuses on history browsing, git gui focuses on authoring commits. However, git gui can launch gitk sessions, and both share Tk interface components.

gitk depends on Tcl/Tk encoding settings and system locale. Encoding problems manifest as corrupted characters in commit messages or file names.

gitk doesn’t provide direct image export, but you can use external tools like git log --graph --oneline | cat and convert to images, or take screenshots of the gitk window.

Use search functionality (Ctrl+F) to find by commit ID, author, or message content. Right-click commits for additional context menu options like copying IDs or marking commits.

gitk shows submodule commits and status but doesn’t provide deep submodule navigation. Each submodule appears as a regular file change in gitk displays.

gitk shows commit-to-commit differences but doesn’t provide line-by-line historical annotation like git blame. For detailed line history, use git gui blame or git blame.

  1. Repository Archaeology: Discovering historical changes and understanding code evolution
  2. Bug Investigation: Tracing when bugs were introduced and by whom
  3. Code Review Preparation: Visualizing complex merge histories and branch interactions
  4. Release Analysis: Understanding what changed between releases and version tags
  5. Educational Exploration: Visual learning of Git branching and merging concepts
  6. Repository Maintenance: Identifying unusual commit patterns or branch structures