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?
Asked
Active
Viewed 44 times
-1
-
https://www.atlassian.com/git/tutorials/rewriting-history - commit with --amend – Shimon Cohen Aug 23 '20 at 18:08
-
Just stage your new changes and do `git commit --amend`. – Ramesh Thiruchelvam Aug 23 '20 at 18:10
2 Answers
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