sainture
11/12/2017 - 10:16 PM

git commit --amend

amend your last commit message or add more files to the same commit

# One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to redo that commit, make the additional changes you forgot, stage them, and commit again using the --amend option:

# As an example, if you commit and then realize you forgot to stage the changes in a file you wanted to add to this commit, you can do something like this:
  git commit -m 'initial commit'
  git add forgotten_file
  git commit --amend

# You end up with a single commit, the second commit replaces the results of the first.

# If you’ve made no changes since your last commit (for instance, you run this command immediately after your previous commit), then your snapshot will look exactly the same, and all you’ll change is your commit message