git diff
您可以对当前文件或项目进行diff,将其与存储在版本库中的最新版本进行比较,并显示差异。
- 要查看当前文件的更改,请访问Tools >Git >Current File ,然后选择Diff of <file> 。
- 要查看当前项目目录中的更改,请访问Tools >Git >Current Project Directory 并选择Diff Directory of <project directory> 。
- 要查看本地版本库中的更改,请转到Tools >Git >Local Repository 并选择Diff 。
Git Diff 视图以只读编辑器显示差异。如果Qt Creator 可以访问文件,则可以双击差异块,打开显示文件和行的编辑器。
Git 差异库视图
切换统一视图和并排视图
Git Diff 视图显示并排差异。要使用统一差异视图,请从工具栏中选择Switch to Unified Diff Editor (1) 选项。
在项目视图中显示 Git 状态
要在 "项目"视图中以不同颜色显示已更改的文件,请转到 "首选项" >Version Control >General ,然后选择Show VCS file status 。
阶段化和非阶段化修改
将更改分阶段提交,以便推送到远程版本库或发送给 Gerrit 进行审核。要逐块或逐行提交变更,可右键单击Git Diff 视图中的某块或某行,然后选择上下文菜单命令来提交或取消提交。
上下文菜单项 | 描述 |
---|---|
Revert Chunk | 重置数据块中的更改。 |
Stage Chunk | 将数据块添加到暂存区域。 |
Stage Selection | 将所选线段添加到暂存区域。 |
Unstage Chunk | 从暂存区域删除该块。 |
Unstage Selection | 从暂存区域移除选定的行。 |
查看已暂存更改的差异:
- 要查看当前文件中的暂存更改,请访问Tools >Git >Current File 并选择Diff Staged Changes in <file> 。
- 要查看当前项目目录中的暂存更改,请转到Tools >Git >Current Project Directory 并选择Diff Staged Directory of <project directory> Changes 。
- 要查看本地仓库中的暂存更改,请转到Tools >Git >Local Repository 并选择Diff Staged 。
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.