4 ms·
> How is "reflog" the correct and intuitive choice for "undo"? Was there something I wasn't understanding? No, I'm just supposed to accept that. Actually your
by nocman 4y ago
> How is "reflog" the correct and intuitive choice for "undo"? Was there something I wasn't understanding? No, I'm just supposed to accept that.
Actually your initial intuition was correct. There are things you obviously don't understand about git. "reflog" is short for reference log. As "git help reflog" will tell you:
Reference logs, or "reflogs", record when the tips of branches and other references were updated in the local repository.
It isn't arcane. It's perfectly logical choice for what the "git reflog" comand does, as explained in the man page: "This command manages the information recorded in the reflogs."
Now if you don't know what a reflog is, you will be confused by this. But the solution to that is for you to learn what a reflog is. And yes, in order to use git well you need to have at least a rudimentary understanding of how it works.
I know that some people do find git hard to understand. Often that is because they want it to work a different way than it does. But git is a fairly complex tool designed to solve a very complex problem. It does an outstanding job of doing what it was designed to do. However, if you are not willing to invest the time in understanding git to a minimal level (and many people aren't), you will find it to be confusing.
There is no need for "sanity" to "come to the naming of commands" for git. The commands already have sane names. But if you don't know what those names mean, it will seem to you as if they are in a foreign language. Most of the confusion people have with git is due to them having an insufficient level of knowledge of how it works. Again, if you want to use git well, you have to gain that minimal knowledge . If you are not willing to do that, then you should either become willing or choose to use some other version control program that is more to your liking.
- at_a_remove 4y agoYou have made my point for me. "This command manages the information recorded in the reflogs." WHAT? Of course everything has an obvious name if you have to learn everything about it. The point I am making is that the name ought to be obvious before you have to learn everything about it. "Undo" is a reasonable choice if you barely understand what git is for and "reflog" is not. Once you master a system and agree to all of its axioms and warts, it's all logical from the inside. That's true of almost any system, though.
- nocman 4y agoYou have made my point for me. There is a minimum level of knowledge you need to know to use git. It is not as straightforward as, say a simple text editor. The problem git is solving is more complex than that, and therefore understanding how to use it requires investing a significant amount of time in learning how it works. If I was going to go back to my previous commit, I would use "git reset" to go back to the commit prior to the one I just committed. The only reason to use "git reflog" as part of that process is to see which commit was prior to the one you are working with now (in order to pass it to "git reset" to undo the changes). > "Undo" is a reasonable choice if you barely understand what git is for and "reflog" is not. But "git reflog" is not an undo mechanism. It can be used to determine a commit SHA to reset to (in order to 'undo' the last commit with "git reset"), but it is used for a bunch of other things also. It is appropriately named for what it does. If you "barely understand what git is for" then the solution is to learn the minimum you need about git in order to use it effectively. I am not talking about mastering git, that's an entirely different topic. I'm talking about basic-level knowledge. Again, the required initial time investment for git is significant, but in my opinion it is worth it. If you don't feel the investment is worth it, then you should use something else.
- nocman 4y agoAlso, if you don't want to use "git reflog" at all for "undoing", you could undo your previous commit with: git reset HEAD^ Or if you also want to discard the changes you made to files in the repo at the same time: git reset HEAD^ --hard But use the --hard option wisely. Be sure you really don't want to keep any of the changes you made (or that you have already saved them elsewhere before running it).
- kingboss 4y agoNo. You are being deliberately obtuse. There is no way to argue that "reflog" is something that is intuitive or that should be known by somebody who just wants to commit on branches and merge them sometimes. Which is what most people need git for. If the minimum level of knowledge to operate a car is to know what every piece of it does and how to reassemble it from scratch the designer of said car hasn't been doing his job. This is exactly the problem with git. You wanted 2 branches and now you have to understand the that the underlying system is actually a filesystem cause that's what Torvalds was used to.