git diff | Qt Creator Documentation

- Qt Creator Documentation
- git diff
- Qt Creator 17.0.1

How To

# git diff

You can diff the current file or project to compare it with the latest version stored in the repository and to display the differences.

- To view changes in the current file, go to Tools > Git > Current File and select Diff of <file>.
- To view changes in the current project directory, go to Tools > Git > Current Project Directory and select Diff Directory of <project directory>.
- To view changes in the local repository, go to Tools > Git > Local Repository and select Diff.

The Git Diff view shows the diff in a read-only editor. If Qt Creator can access the file, you can double-click a diff chunk to open an editor that displays the file and line.

Git Diff Repository view

## Toggle unified and side-by-side views

The Git Diff view displays the diff side-by-side. To use the unified diff view instead, select the Switch to Unified Diff Editor (1) option from the toolbar.

## Show Git status in the Projects view

To show changed files in the Projects view in a different color, go to Preferences > Version Control > General and select Show VCS file status.

## Stage and unstage changes

Stage your changes to commit them, so that you can push them to the remote repository or send them to Gerrit for review. To stage changes for a commit chunk-by-chunk or line-by-line, right-click a chunk or line in the Git Diff view and select context menu commands to stage or unstage it.

Context Menu Item | Description
--- | ---
Revert Chunk | Resets the changes in the chunk.
Stage Chunk | Adds the chunk to the staging area.
Stage Selection | Adds the selected lines to the staging area.
Unstage Chunk | Removes the chunk from the staging area.
Unstage Selection | Removes the selected lines from the staging area.

To view a diff of staged changes:

- To view staged changes in the current file, go to Tools > Git > Current File and select Diff Staged Changes in <file>.
- To view staged changes in the current project directory, go to Tools > Git > Current Project Directory and select Diff Staged Directory of <project directory> Changes.
- To view staged changes in the local repository, go to Tools > Git > Local Repository and select Diff Staged.

See also How To: Use Git and Git.

How To