To start this tutorial, I created a file and I'll use to test.
Let's imagine that in the last command we wrote like this:
git commit -m "adding fils"
To fix, simply type:
git commit -m "adding files" --amend
Two important commands that git give us
git --hard and
HARD = is usually used when we messed up the code and want to get everything back to how it was before you messed with it. It's an undo-like function, so be careful.
SOFT = On the other hand, we have Soft, which will remove the commits from our commit list without removing the changes from the commits.
And in our case, we want to delete the last three commits.
git reset --soft HEAD~3
And we can confirm by putting
We also confirm that the files are to be committed
Inteface experience Git by terminal
Another way (the most correct according to the documentation) is to give the following command:
git rebase -i HEAD~3
And we can (we must) change the command pick to squash
When recording, another screen will appear, informing what was done.
Also, it will ask us to put a decent message.
I hope I have helped you.
Top comments (2)
For anyone who wants to apply rebasing interactive, please ensure you do that BEFORE pushing anything to the remote repository. Otherwise, you'll have to force things which should be the very last resort.