I have been working with git for just over a month. Indeed I have used reset for the first time only yesterday, but the soft reset still doesn\'t make much sense to me.
"Oops. Those three commits could be just one."
So, undo the last 3 (or whatever) commits (without affecting the index nor working directory). Then commit all the changes as one.
> git add -A; git commit -m "Start here."
> git add -A; git commit -m "One"
> git add -A; git commit -m "Two"
> git add -A' git commit -m "Three"
> git log --oneline --graph -4 --decorate
> * da883dc (HEAD, master) Three
> * 92d3eb7 Two
> * c6e82d3 One
> * e1e8042 Start here.
> git reset --soft HEAD~3
> git log --oneline --graph -1 --decorate
> * e1e8042 Start here.
Now all your changes are preserved and ready to be committed as one.
Are these two commands really the same (reset --soft vs commit --amend)?
Any reason to use one or the other in practical terms?
commit --amend to add/rm files from the very last commit or to change its message. reset --soft to combine several sequential commits into a new one.And more importantly, are there any other uses for reset --soft apart from amending a commit?