Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
April 29, 2022 12:18 pm GMT

How to fix a commit?

To start this tutorial, I created a file and I'll use to test.

Start tutorial

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 git soft

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.

git log

And in our case, we want to delete the last three commits.

git reset --soft HEAD~3

And we can confirm by putting git log
confirmation git reset

We also confirm that the files are to be committed
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

git rebase -i

And we can (we must) change the command pick to squash

When recording, another screen will appear, informing what was done.

recording

Also, it will ask us to put a decent message.

done

The result
The result

I hope I have helped you.


Original Link: https://dev.to/ramirezmz/how-to-fix-a-commit-blh

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To