Use git commit --amend to add new changes to the previous commit i.e., HEAD~{0}
Aneesh
Posted on June 23, 2023
Imagine you've just made a commit, feeling confident about the code changes you've implemented. However, upon further inspection, you notice a small adjustment that should have been part of the previous commit. Here's where "git commit --amend" comes to the rescue.
To tackle this situation. First make the required changes in the code and stage it.
Once you've staged the changes, it's time to amend the previous commit. Run the following command:
git commit --amend
This command opens the default text editor (such as Vim or Nano) with a pre-filled commit message. You can modify the message if necessary. Additionally, the staged changes are automatically incorporated into the previous commit.
Close the text editor after editing the commit message. Now, the new changes and the previous changes are merged into one commit.
Posted on June 23, 2023
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.