There are several problems with this concept:
Not all operations are reversible. Sometimes this happens due to the fact that Git does not write enough information to display the previous state - it would be too expensive in general. Sometimes it is like git reset --hard
or git clean
, which destroy irreparable changes. To cancel them, it must be automatically automatically backed up. Sometimes this happens because the concept of undo is ambiguous - as you yourself indicated, there are many ways to undo a commit.
If the operation is reversible, and it is associated with some history, should it be canceled / repeated in the history, or should they disappear? If a commit is canceled by resetting back or by returning (creating another commit to cancel it)?
Without writing down the last thing you do, how would you know what happened in the last operation? Say you added a file to the index and created a branch. There is no record of what was first.
Even if everything was clearly defined, this would be an absurd job. How do you decide what constitutes one action? One Git team can do many things. If he cancels one step, is that all? What if you run millions of commands, each of which performs a tiny step, and you want to undo all this? And it must be perfect, completely perfect, because this is the type of function that will be used by inexperienced users who have no idea how to recover from any mistake.
So, just like Git provides you with the tools to work, it gives you the tools to see what you have done and undo everything yourself if necessary.
In addition, as for the “repeat”, as you defined it in your question, he repeats the command, and does not perform the original operation again. When you rewrite a commit, it was different. Repeating the previous command is what was designed for the command line. Git does not need to reinvent it.
Cascabel
source share