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:
- Locate the hunk containing the lines you want to stage
- Select the lines you want to stage (using the mouse or keyboard)
- Select the button that appears at the top of the hunk
Note: You can also unstage lines using the same functionality
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.
- Stage the changes you'd like to add to the most recent commit
- Select the dropdown next to the commit button
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
To redo an entry in the reflog, select via the application menu.
Note: Any changes undone will be shown in the staged files section
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.