Now Up To  80% OFF  GitKraken Pro
Upgrade to Save
Search
Close this search box.

How do you amend a Git commit?

We can all relate with this situation: you’ve just committed changes only to realize you misspelled something in the Git commit message. Or maybe you need to make a change to another file that really should be part of that commit.

Sure, you could let that “teh” slide, or just make another commit with your overlooked changes, but c’mon you’re better than that! Thankfully, Git offers a few options for how to undo a Git commit, including how to revert a commit, but we’re going to walk through how to amend a Git commit, first using the GitKraken Git GUI and then using the command line.

Amending your last commit and editing commit messages are quick and easy with GitKraken

How do you amend a commit message in GitKraken?

Editing the message of your most recent commit is insanely simple using GitKraken. After selecting a commit from the central graph, just click the message at the top of the right commit panel to start editing, then click Update message to save your changes.

How do you amend your last commit in GitKraken?

The process of adding new changes to your last commit in GitKraken is extremely easy. No need to remember or run any commands.

After staging your changes, check the box next to Amend near the commit message and then click Amend Previous Commit. You can also easily edit the Git commit message here before committing your changes.

How do you amend a Git commit in the command line?

git commit --amend is a Git command tailor-made to preserve your grammatic integrity and maintain repository cleanliness. It will allow you to edit your Git commit message or change the content of the last commit you’ve made.

How do you amend a Git commit message in the command line?

The following methods will create a new commit with an updated message that replaces the previous commit. To change a Git commit message in the command line, you will run the following:

git commit --amend -m “new commit message”

Unlike in GitKraken, where you can simply select a commit from the central graph to see its related commit message, you have far less visibility in the terminal. If you want to see the Git commit message before editing in the CLI, you can leave off the -m flag and simply type: git commit --amend.

But keep in mind, using this method requires editing the commit message in VIM, so you will need to type i to enter INSERT mode to change the message, and then esc to exit INSERT mode, and then :wq to save your changes and quit.

That’s at least four additional steps required to edit a Git commit message in the CLI when compared to GitKraken. But hey, who’s counting. 😉

How do you amend your last commit in the command line?

To amend a commit to only include new changes in the CLI, you will first need to stage any changes from your working directory that you want in the new commit.

To amend a Git commit to include new changes without updating the commit message, you will run:

git commit --amend --no-edit

If you want to change the contents of your last commit and also edit the Git commit message, you can pass in the -m flag instead of --no-edit.

git commit --amend -m “new commit message”

Add more flexibility to your workflow and make amending Git commits, whether you’re editing a Git commit message or amending your last commit, with the help of the cross-platform GitKraken Git client for Windows, Mac, and Linux.

Additional Resources

Table of Contents

Make Git Easier, Safer &
More Powerful

with GitKraken

Visual Studio Code is required to install GitLens.

Don’t have Visual Studio Code? Get it now.

Team Collaboration Services

Secure cloud-backed services that span across all products in the DevEx platform to keep your workflows connected across projects, repos, and team members
Launchpad – All your PRs, issues, & tasks in one spot to kick off a focused, unblocked day. Code Suggest – Real code suggestions anywhere in your project, as simple as in Google Docs. Cloud Patches – Speed up PR reviews by enabling early collaboration on work-in-progress. Workspaces – Group & sync repos to simplify multi-repo actions, & get new devs coding faster. DORA Insights – Data-driven code insights to track & improve development velocity. Security & Admin – Easily set up SSO, manage access, & streamline IdP integrations.
winget install gitkraken.cli