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}

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 ItemDescription
Revert ChunkResets the changes in the chunk.
Stage ChunkAdds the chunk to the staging area.
Stage SelectionAdds the selected lines to the staging area.
Unstage ChunkRemoves the chunk from the staging area.
Unstage SelectionRemoves the selected lines from the staging area.

See also How To: Use Git and Git.

Copyright © The Qt Company Ltd. and other contributors. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.