> Here’s my theory: novice and intermediate users would significantly improve their understanding and efficacy with Git if they weren’t afraid of making mistakes. Agreed. When I was learning to climb the instructor told me I would never reach my full potential until after the first fall. You cannot work at your limit until you trust the rope. However, I think this is still avoiding the rope. Git is really simple and…
Git undo: We can do better
131–140 of 490 posts
Re: Git undo: We can do better
#132> novice users are terrified of it. When they make a mistake, many would rather delete and re-clone the repository than try to fix it In my experience most beginners use a GUI like Atlassian Sourcetree or the Github desktop client. It's a lot harder to make mistakes using the GUI in my experience. I still really like this idea though; eventually a subset of the beginners wants to learn the git cli and that sure seems…
Re: Git undo: We can do better
#133Earlier quoted context omitted.
Hard disagree, git's docs and UI have improved over the years but every time I have to teach it to a beginner I realize how arcane and scary it is, especially when compared to old school centralized VCSs like subversion. Not that I'd trade git for subversion mind you, in the hands of a trained individual git is a godsend, but the training part can be arduous. Even among DVCSs I'd argue that mercurial for instance is…
If it's an issue of having to read the docs or the man, well I've been at work like this for a little over a decade and I still have to pull up a reference when I want to do something nontrivial in, not only git, but pretty much every cli tool I use on a regular basis. Cli tools, frameworks, libraries, languages... I have to pull up a reference for everything I do as a programmer, so it's hard for me to muster up the…
Wait, how do I remove it from staging? It seems there should be some symmetric operation, `git remove ` or something. Maybe git rm ``, whoa don't do that.
No, it is `git reset HEAD -- `. There is no mental symmetry.
Or why use add at all? What am I adding it to? It is so generic, why not `git stage file` and `git unstage file`?
I agree that you need to read and learn tools, but there is a lack of consistency and symmetry in many of the commands which make it harder.
Re: Git undo: We can do better
#134git config --global alias.undo 'reset --soft HEAD~1' Not that I would include this in my own shell. To the authors two example uses: 1) Undoing an amended commit. But if you're comfortable amending a commit, can't you just amend your amended commit? 2) Accidentally commiting an incorrectly resolved merge conflict. Revert the change if you want to be non-destructive. Reset HEAD~1 otherwise.
2. Yeah, but I think the UX improvement of a single command to say “Go back to where I was” is reasonable.
Re: Git undo: We can do better
#135Earlier quoted context omitted.
I know (or, at least, have known ) how git works, in the way most people mean that (the data structures & on-disk layout, what a commit is, what a tag is, what a branch is, what HEAD is, staging, et c.). What I can't keep straight is WTF the commands are actually doing, in that low-level sense, which is a different thing, and there's approximately a 0% chance I'm ever going to use more than a tiny fraction of the com…
Yes. Especially git init --submodule --recursive Or is it git submodule --init --recursive? God I hate this UX so much I usually have a ./fetch-subrepos.sh that runs a bunch of "git clone" commands. And if I push without first pulling, must it always punish me with a merge commit? Can't I say "oh shit I don't want to do this, go back and git pull"?
I think I know git well, but you got me confused. I've never heard of pushes causing merges. Surely you are talking about pulls, right?
Re: Git undo: We can do better
#136Earlier quoted context omitted.
I come across this attitude a lot. Usually my response is if you use something daily, and you know you lack the skills to use it effectively, why don't you improve your knowledge and seek out training or education? Do you treat a new programming language or framework with the same disdain? I know I'm gonna get some hate for pointing this out but this same disdain is what causes things like the branchless workflow. A…
At one time I was an expert in 'C'. I was the goto guy at our company for porting and performance issues and was often just handed the entire project if it involved porting. I have no memory of any of that beyond the basics now. Git is like that. There is no way I will remember commands I only use once a quarter or so when something goes wrong.
Re: Git undo: We can do better
#137While GitUp is a GUI app, and only available for macOS, I think it's worth noting that it has some great undo/redo capabilities built in. From what I understand, some of them were more feasible to develop because they implemented their own plumbing (GitUpKit), instead of relying on the official git plumbing. https://gitup.co/
GitUp is such a great app & fantastic UI design, but the author gave up on it at maybe 80% of functionality, and I think for that reason (among perhaps others), it never really caught on. (It's open source and there are still occasional commits, but it doesn't seem to be really actively worked.) Nevertheless my main daily driver, along w/ the command line. It's undo capabilities, best-in-class visualization of the ti…
Re: Git undo: We can do better
#138Earlier quoted context omitted.
Yes. Especially git init --submodule --recursive Or is it git submodule --init --recursive? God I hate this UX so much I usually have a ./fetch-subrepos.sh that runs a bunch of "git clone" commands. And if I push without first pulling, must it always punish me with a merge commit? Can't I say "oh shit I don't want to do this, go back and git pull"?
It is for this reason that I have changed my workflow to always stash first, then pull, then pop the stash and do the merges locally, then push.
Re: Git undo: We can do better
#139From the article: > How is it so easy to “lose” your data in a system that’s supposed to never lose your data? I think the author is mistaken; git isn't "a system that’s supposed to never lose your data". One of its features is the ability to "lose" data in a controlled way; i.e., to rewrite history. If you want a version control that is supposed to never lose data, use Fossil.
It’s extremely difficult to lose anything in Git once it’s been committed. You’d have to do something pathological or intentional.
Re: Git undo: We can do better
#140* the working copy
* the graph
And it gets better, if any file gets disconnected from the graph, it can be hard to locate. (Yes I know, it can be found in the reflog)