-1

Is it possible to commit your changes as part of a previous commit? Like add to your most recent commit with whatever you just changed?

Palpable Coral
  • 105
  • 1
  • 2
  • 12

2 Answers2

0

Yes, it's called amending.

git commit --amend

You can even change the commit message of the last commit.

git commit --amend --message "my new message"

It's worth knowing that even though the commit is the same one from a human perspective, the SHA hash will change, so if you were referring to it by hash for any purpose, the reference won't work anymore.

meedstrom
  • 341
  • 2
  • 7
0

If you want to turn the last two revisions into a single one:

git reset --soft HEAD~
git commit --amend --no-edit # use the message from the (originally) 2nd to last revision

Or, you could set up a new message:

git reset --soft HEAD~
git commit --amend -m "new message"
eftshift0
  • 26,375
  • 3
  • 36
  • 60