Remove the last git-commit without changing the project files.
-
I have a local repository of my project. There are a few commites. The last comedian was made unthinkable (it was recalled that there were a couple of problems that would not like to perpetuate). I can go back to my previous committ. But that's not what I need. So I'm gonna lose a lot of useful work done between the previous committ and the last one.
Anyway, I want to make sure there's no last room, but all my files were just like they are now.
-
Take out the last comedian.
console
We just remove the last comedian from the branch where we're in. The branch indicator will move on to the previous one. All changes made in this room will remain in the project area (i.e. in the CD files).
git reset HEAD^
The same, plus all changes of the last commite, will be added to the index. You can make a new committ.
git reset --soft HEAD^
GUI
Android Studio can do the same: View , Tool Windows , Version Control♪ Log, there's a PKM on the previous room, Reset Current Branch to Here (Elect Soft)
editing (reconstructing) the last comedian
The last comedian was made unthinkable (it was recalled that there were a couple of issues that would not like to perpetuate)
It's also possible.
editingreplace new ones. Just add to the index all the files you need in a state that's worthy ofboxing in the bronze and marble.git add file1 file2 folder git commit --amend --no-edit
Key
--amend
Tells the git that it is necessary not to create a new comedian, but to retrieve the last one. This cannot be described as editing, as the commites are unreplaceable (immutable) objects, as lines in Java.Key
--no-edit
Says git we don't want to change the comment of the last comment. Instead, a new comment could be made:git commit --amend -m'bla bla bla'
There's also a graphic way to do this: a special necklace in the commite window: