Sublime Merge Tips - Creating and Updating Commits

May 10, 2021 by Dylan Johnston All Posts

Sublime Merge Tips is where we share our favourite tips to be productive with Git and Sublime Merge.

In this entry we'll be exploring ways to create, update, and undo commits.

If you missed part one of Sublime Merge Tips, you can start here

Staging and Unstaging Lines

Want to stage a couple of lines from a file? No problem!

Staging lines is simple using Sublime Merge:

  1. Locate the hunk containing the lines you want to stage
  2. Select the lines you want to stage (using the mouse or keyboard)
  3. Select the Stage Lines button that appears at the top of the hunk

Note: You can also unstage lines using the same functionality

Staging lines


Amending a Commit

It's easy to create a commit, but how about updating a commit?

git commit --amend will allow you to quickly update the contents of the last commit.

  1. Stage the changes you'd like to add to the most recent commit
  2. Select the dropdown next to the commit button
  3. Select Amend Previous Commit

Amending a commit

Undoing the Last Commit

A Git repository has the concept of the reflog - a file containing the history of updates to refs (branches, tags etc). You can view the contents of the reflog using the Git command git reflog

Using Sublime Merge you can also easily step back and forward through the reflog. This allows you to undo and redo actions such as committing and resetting.

To undo an entry in the reflog, select Repository ▶ Undo via the application menu.
To redo an entry in the reflog, select Repository ▶ Redo via the application menu.

Note: Any changes undone will be shown in the staged files section

Undoing a commit

Get Started with Sublime Merge

Sublime Merge is a graphical Git client from the creators of Sublime Text that makes using Git a breeze.
Visit the download page to get started.