Live data from Hacker News

Things I wish everyone knew about Git (Part I)

blog.plover.com

41–50 of 200 posts

Re: Things I wish everyone knew about Git (Part I)

#41

haha, i cant count the times i fucked up and i just copied my files out, rm -rf repo; git clone; copy in :)

Seriously, probably faster than searching for the command you need to fix it with all the right options that if not set would amplify your issues

Re: Things I wish everyone knew about Git (Part I)

#43
post #4

I'm pleased the coming Part II purports to point to `reflog`. For a tool that _looks_ like it's fairly advanced, this is one of my favorites to show juniors, because it works so well as a "get me back to where I was" hack.

`git reflog`[0] saved my sanity numerous times.

[0]: https://git-scm.com/docs/git-reflog

Re: Things I wish everyone knew about Git (Part I)

#46
post #24
post #11

> But if I were going to tell everyone just one more thing, it would be: > It is very hard to permanently lose work. Unfortunately, this is not quite true. Git checkout will silently and irretrievably clobber all the changes in your working tree [UPDATE: if you do 'git checkout [path]', but that is not an uncommon thing to do.] It is true that it is very hard to lose work that you have committed. But even this is not…

> Unfortunately, this is not quite true. Git checkout will silently and irretrievably clobber all the changes in your working tree. Not by default it won't. It can do that, if you explicitly run it with the options to checkout a specific path. But why would you do that if it's not what you want?

"Just don't make a mistake" is a pretty bad strategy.

Re: Things I wish everyone knew about Git (Part I)

#47
post #40
post #24

Earlier quoted context omitted.

> Unfortunately, this is not quite true. Git checkout will silently and irretrievably clobber all the changes in your working tree. Not by default it won't. It can do that, if you explicitly run it with the options to checkout a specific path. But why would you do that if it's not what you want?

> It can do that, if you explicitly run it with the options to checkout a specific path. Fair point. I've update my comment to clarify. > But why would you do that if it's not what you want? Because sometimes it is what you want. The point is, if you happen to do it when it's not what you want, you're hosed. So it is simply not true that "It is very hard to permanently lose work." It is, in fact, quite easy under cer…

Fair point. There probably should be standard advice along the lines of "if in doubt, make a 'wip' commit before you do anything". That's good advice even beyond using git itself.

Re: Things I wish everyone knew about Git (Part I)

#48
I'm not a fan of this mythos around Git's complexity. It is simply a DAG, a bunch of references to nodes in that graph, and a stack of commands that let you make any modification to that system you so desire.

If you just learn the mapping of those concepts to Git's vocabulary, you really don't need to memorize all the commands. In the odd case, you can just look up the docs. Nodes are commits, references are either branches or labels depending on whether they stick to leaf nodes or any other node. Your working tree is the current state of the repo in your filesystem, and staging is how you assemble commits.

Re: Things I wish everyone knew about Git (Part I)

#49

I'm not a fan of this mythos around Git's complexity. It is simply a DAG, a bunch of references to nodes in that graph, and a stack of commands that let you make any modification to that system you so desire. If you just learn the mapping of those concepts to Git's vocabulary, you really don't need to memorize all the commands. In the odd case, you can just look up the docs. Nodes are commits, references are either b…

There's a strong current in all tech things where "I couldn't figure it out intuitively the first time I sat down and tried it" becomes exactly the same as "this is ungodly complex and impossible to use".

I've seen it leveled against emacs, git, vim, etc. It's kind of sad.

I suspect that "attempts to explain something in an easy (but subtly wrong) way" have fueled it with regards to git.

Re: Things I wish everyone knew about Git (Part I)

#50
If you can understand the data structure git uses (Merkel Trees) it becomes easy to understand git (won't help with the CLI though).

I think it can be summarized as Linked List in reverse. New entries are always added on head instead of tail. The pointer used to track the growing list is 'branch' pointer. The pointer that is fixed to a specific node is 'tag'. Since we are adding on Head, we can have multiple nodes point to one node.

Post reply on HN