Amend a Git Commit
If you left out some files from a commit or modified some files after a commit, and it’s more appropriate to include these changes in the currently staged commit rather than making a new commit, you can amend the commit, adding these extraneous files.
First stage the files you wish to add to the commit:
git add [file1 file2 ...]
Then add them to the current commit thusly (you have two options):
# with the existing commit's message
git commit --amend -C HEAD
# or with a new message:
git commit --amend -m "Your message."
FYI, the -C option is documented as follows:
-C <commit>, --reuse-message=<commit>
Take an existing commit object, and reuse the log message and the authorship information (including the timestamp) when creating the commit.
Written by Robbie Pitts
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Shell
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#