Skip to content
Tutorials Center
My learning

Topics

Lesson 7 of 78 ยท Getting Started

Git GUIs and IDE Integrations

Tour the graphical and terminal-UI Git clients - gitk, git gui, VS Code, JetBrains IDEs and lazygit - and learn what they run underneath, so you can mix them with the CLI.

You do not have to type every Git command. Many developers stage lines in an editor, browse history in a graph and resolve conflicts in a three-pane window. Those tools are not magic: almost all of them are a friendly face on the same commands you have been learning. A client draws a picture, you click, and it runs git add, git commit or git log for you.

This lesson tours the clients you are most likely to meet: gitk and git gui (shipped with Git), the Git support in VS Code and the JetBrains IDEs, and the terminal UI lazygit. You will also learn how to see exactly what a client runs, which of its features beat the command line, and how to mix both styles safely. The sandbox has no screen, so the windows themselves are described in words, but every command a client relies on is run for real below.

What a Git client really is

Every client does two things: it reads repository state (status, log, diff, branches) and it writes by running Git operations. Most read the state by running plumbing-friendly commands and parsing the output; a few embed a library such as libgit2. Either way the data is the same data you see in the terminal, because the repository on disk is the only source of truth.

flowchart LR
    U["You click or press a key"] --> C["Client: gitk, IDE, lazygit"]
    C -->|"runs commands"| G["git (the CLI)"]
    G --> R[".git folder and working tree"]
    R -->|"output is parsed"| C
    C -->|"draws graph, diff, lists"| U

A client is a layer between you and the same Git commands. The repository is shared, so the CLI and any client always agree.

This has a practical consequence: you can switch between a client and the terminal at any moment. Stage with the GUI, commit in the terminal, rebase in the IDE; nothing gets out of sync, because nothing is stored in the client except its own settings.

gitk: the history browser

gitk is a viewer written in Tcl/Tk and installed with Git (on Windows it is in the Git for Windows start menu; on Debian-based Linux it is a separate gitk package). Run gitk in a repository and you get a window with the commit graph on top, the selected commit's message and changed-files list below, and a diff pane. You can search commit messages, filter by author or path, and click a parent hash to jump to it. gitk --all shows every branch, not only the current one, and gitk path/to/file shows the history of a single file.

What the graph shows is the output of git log --graph. You can produce the same data in a terminal:

Bash The data behind a history graph

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

The second listing is the heart of it. Each commit has a short hash, a list of parent hashes and a subject. A client only needs the parent column to draw the lines of the graph: the merge commit lists two parents, so two lines join there.

git gui: staging and committing

git gui is gitk's sibling for writing. Its window has four panes: Unstaged Changes (top left), Staged Changes (bottom left), the diff (top right) and the commit message box (bottom right). Click a file's icon to move it between the two lists. Right-click inside the diff to Stage Hunk or Stage Line, which makes it a convenient way to split one messy edit into two clean commits. It also has menus for amending the last commit, creating branches and pushing.

Staging a hunk in a GUI is the same thing as the interactive patch mode of git add -p. Partial staging is the single feature where a graphical tool is usually nicer than the CLI, because you see the whole file and click the lines you want. Here is the result of partial staging, checked from the terminal:

Bash Stage part of a file, as a GUI does

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

The first edit went into the commit and the second stayed behind as a modification. In git gui, VS Code and the JetBrains IDEs you do the same with a click on the hunk or a selected line range.

VS Code

Visual Studio Code has a built-in Source Control view (the branch icon in the left bar, or Ctrl+Shift+G). It finds the git executable on your machine, so Git must be installed first. What you get out of the box:

  • A list of changed files with letters: M modified, A added, U untracked, D deleted, C conflict. Click a file for a side-by-side diff.
  • A message box and a commit button. The drop-down next to it can commit and push, or amend.
  • Stage, unstage and discard icons per file, and "Stage Selected Ranges" for partial staging in the editor.
  • A branch name in the status bar. Click it to switch or create branches; the arrows next to it show how many commits you are behind and ahead of the upstream (push, pull and Tracking Branches).
  • A merge editor with Current, Incoming and Result panes for conflicts (Resolving Merge Conflicts).
  • Inline blame hints on the current line when an extension such as GitLens is installed; the built-in Timeline view lists the commits that touched the open file.

The letters in that list are the short status codes you already know. The terminal gives you the same list:

Bash The letters VS Code shows come from this

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

In the short format the first column is the staging area and the second is the working tree. A is staged-added, M is modified but not staged, D is a staged deletion and ?? is untracked. The --porcelain form is a promise from Git that the layout will not change between versions, which is exactly why tools parse it instead of the human-readable git status.

JetBrains IDEs

IntelliJ IDEA, PyCharm, PhpStorm, WebStorm, GoLand and the other JetBrains IDEs share one Git integration. The ideas map directly to the commands:

  • Commit tool window (Ctrl+K / Cmd+K): tick the files, or even single changed lines (the checkboxes in the gutter), then commit. Ticking is staging. Newer versions let you switch between this changelist style and a classic staging-area style.
  • Git tool window (log tab): a filterable graph with branches on the left and diffs on the right. You can drag commits to reorder, squash or edit them, which runs an interactive rebase (Interactive Rebase).
  • Update Project (Ctrl+T): fetches and then merges or rebases, depending on your choice. Know which one is selected, because the default has changed between versions.
  • Shelve and Stash: shelving is an IDE-only feature stored outside Git; stashing is the real git stash (Stashing Your Work).
  • Annotate with Git Blame: right-click the gutter to show author and date per line (Blame and Searching History).
  • A three-way merge dialog with left, result and right panes, plus buttons that apply all non-conflicting changes at once.

JetBrains IDEs run your git executable (set in Settings, Version Control, Git), so your hooks, your config and your credentials apply exactly as in a terminal.

lazygit: a keyboard-driven terminal UI

lazygit is a separate program (not part of Git) that draws panes in your terminal: files, branches, commits, stash and a diff. You move with the arrow keys and act with single letters, for example space to stage a file, c to commit, P to push, and p to pull. A popup shows the command that was run, and its command log panel prints every Git command it executes. That makes it a good teacher, since each key press is a real command you can learn.

Its strength is the speed of tasks that need many keystrokes in the CLI: moving a line range into a new commit, reordering and squashing commits in an interactive rebase, or cherry-picking from several branches (Cherry-Pick). Similar terminal UIs exist for other tastes, such as tig (a read-mostly history browser).

Choosing between a GUI and the CLI

Neither is better in general. A few honest rules of thumb:

Task Often easiest in Why
Reading a long, branchy history a GUI graph you see the shape at once
Partial staging of a file a GUI or git add -p per-hunk and per-line clicks
Resolving a large conflict a three-pane merge editor side-by-side context
Scripts, CI, servers the CLI no screen, repeatable
Rare or advanced commands the CLI clients expose only common options
Learning what is going on the CLI, or a client's command log the commands are the model

Two habits keep you safe with any client:

  1. Learn the command behind the button. "Sync", "Update", "Fetch and rebase" and "Undo" are shortcuts for several commands, and their names differ between tools. If you do not know what a button runs, read the client's log or hover for the tooltip before you press it.
  2. Check the result in the terminal when it matters. git status and git log --oneline --graph --all show the truth. They are quick and tell you whether the client did what you expected.
Bash Check the truth after any client action

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

The button labelled "Undo Last Commit" in many clients ran git reset --soft HEAD~1: the commit is gone from the history, but its changes are still staged. Seeing that in the terminal removes the mystery (see Reset in Depth).

Settings that make tools cooperate

Because every client reads the same configuration, a few settings help all of them:

CONSOLE
$ git config --global core.editor "code --wait"      # VS Code as the editor for commit messages
$ git config --global merge.tool vscode
$ git config --global mergetool.vscode.cmd 'code --wait --merge $REMOTE $LOCAL $BASE $MERGED'
$ git config --global diff.tool vscode
$ git config --global difftool.vscode.cmd 'code --wait --diff $LOCAL $REMOTE'
$ git config --global gui.encoding utf-8

git mergetool and git difftool hand the files to the program you configured, so a graphical diff is available from the terminal as well. You can see which tools your Git knows about:

Bash Which diff and merge tools does Git know about

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with read or cat), it gets the next line from this box.

The list says which tools Git can launch if they are installed, and which are available on this machine (in the sandbox none are). Your own computer will show your editor under "available".

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. What is the relationship between a Git GUI and the repository?

    The repository on disk is the single source of truth. A client reads it and runs ordinary Git operations, so you can switch between the client and the terminal at any time.
  2. 2. Which pair is gitk and git gui designed for?

    gitk is the history viewer (graph, search, diffs) and git gui is for staging hunks and lines and writing commits. Both ship with Git.
  3. 3. In git status --short, what does M (a space, then M) mean?

    The first column is the staging area and the second is the working tree. A space in the first column and M in the second means an unstaged modification.
  4. 4. Why do tools parse git status --porcelain instead of the normal output?

    Porcelain output is guaranteed not to change, so programs can rely on it. The human-readable text may be reworded in new versions.
  5. 5. A client button called "Undo Last Commit" most likely runs which command?

    Undoing the last commit while keeping its changes is a soft reset: the commit disappears from the branch and its changes stay staged.

Summary

  • Git clients are friendly layers over the same commands; the repository is shared, so you can mix a client with the terminal freely.
  • gitk browses history as a graph and git gui stages hunks and lines and commits; both ship with Git.
  • VS Code and the JetBrains IDEs have built-in source control with diffs, partial staging, branch switching, blame and merge editors; they run your own git executable and honor your config and hooks.
  • lazygit is a keyboard-driven terminal UI whose command log teaches the commands behind each key.
  • Tools read git status --porcelain and git log --format=... because those formats are stable.
  • Learn the command behind each button, and verify important actions with git status and git log --oneline --graph --all.

Next: Status, Diff and Seeing Changes