Git Commit Perspective

Icon: git commit perspective

Keyboard shortcut: CTRL+SHIFT+O (CMD+SHIFT+O on macOS)

Description

The Git commit perspective is where you review the changes in your project and commit them. It is available when the project folder is a git repository. See Working with git for the other git options in Hop Gui.

The list of changes

The perspective lists your changes in the same three groups git status reports:

Staged

added to git’s index with 'Add', part of the next commit.

Unstaged

changed files that git tracks, but the changes are not in the index.

Untracked

files git doesn’t know about yet, because they were never added.

Add, Unstage, Restore, Delete and Add to .gitignore act on the files whose checkbox is ticked, not on the highlighted row. Show text diff and Show visual diff follow the first highlighted file instead. Staged and unstaged files are ticked for you, so a commit takes your work in progress along: untick a file (or unstage it) to leave it out. Untracked files are listed but never ticked: committing a file for the first time is something you decide, tick it yourself to include it.

icon action description shortcut

refresh

Refresh

Reload the list of staged and unstaged files.

F5

git add

Add

Stage the checked unstaged or untracked files. They move to 'Staged' and become part of the next commit. For an untracked file this is also what puts it under version control.

CTRL+ALT+A

git unstage

Unstage

Take the checked files out of the next commit. They move back to 'Unstaged' (or to 'Untracked' if they were never committed before), your changes are kept.

CTRL+ALT+U

git restore

Restore

Discard staged edits to files git already tracks and restore the last committed version (HEAD). A staged new file is only unstaged and stays on disk, unless 'Delete local copies of added files' is checked. That toggle is off by default. Asks for confirmation.

CTRL+ALT+Z

delete

Delete

Delete the checked files from disk.

DEL

Unstage and Restore both act on staged files, but they do very different things. Unstage only takes a file out of the next commit and keeps your work. Restore discards staged edits to files git already tracks. A staged new file is only unstaged unless you check 'Delete local copies of added files'. That is why Restore asks for confirmation and Unstage does not: nothing is lost by unstaging, you can stage the file again with 'Add'.

The same options are available in the right-click menu of the file list, together with:

  • Add to .gitignore: have git ignore the file from now on.

  • Show text diff (CTRL+D): the changes in the first highlighted file as text. This follows the highlight, not the checkbox.

  • Show visual diff (CTRL+SHIFT+D): for a pipeline or workflow, open the before and after versions of the first highlighted file side by side. This follows the highlight, not the checkbox.

Committing

Enter a commit message below the list of changes, then click:

Commit

commit the checked files.

Commit and Push

commit the checked files and push the commit to the remote.

Tick 'Amend' first to put the checked files into your last commit instead of creating a new one.

CTRL+K (CMD+K on macOS) ticks all staged and unstaged files and moves the cursor to the commit message, so committing all your work in progress is CTRL+K, typing the message and 'Commit'.