Live data from Hacker News

Oh shit, git: Getting myself out of bad situations

ohshitgit.com

401–410 of 520 posts

Re: Oh shit, git: Getting myself out of bad situations

#401
post #187

Earlier quoted context omitted.

It's not anything inherent to a visual UI though, it's just that most of the UIs that exist are trying to put their own model on top of git, rather than embracing git's model. The one exception to this I've found is GitUp (mac only, sadly), and it's excellent. It's whole model is, "what operations can I perform on this graph," which is exactly the model git has. It's great.

I think you've put your finger on the schism of why so many git users prefer a GUI. The built-in porcelain is stupidly inconsistent and confusing. And yet, git's underlying model is so simple and powerful that I think it's worth suffering the bad CLI just to be more fluent and able to utilize git's power fully. The model itself is very easy to grok, it just takes some time to memorize the various random incantations…

It might not feelblike that big of a deal, but certainly there has got to be on any given day far more important things you can use those brain cycles for, yes? Low friction or not it's still friction. Friction that can be removed. Yet so many refuse to do so. There's something wrong with this this-is-how-we've-always-do-it picture.

Re: Oh shit, git: Getting myself out of bad situations

#402
post #11

> Oh shit, I accidentally committed to the wrong branch! I find cherry-picking to be easier in this case. Just checkout the branch and cherry pick commits from 'wrong' branch. https://git-scm.com/docs/git-cherry-pick

I don't see how that's easier. There's `git checkout -b my-new-branch` which is even easier than the originally proposed solution. Followed by `git checkout master && git reset --hard @{u}` or, if you don't want to switch between branches, `git branch -f master master@{u}`.

Re: Oh shit, git: Getting myself out of bad situations

#403

Adopted a git GUI years ago and haven't looked back. I get looks sometimes, but I can't help but gloat when I can stage and unstage individual lines in less than a second. I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI. Takeaways: - My commit time is usually much faster than coworkers, with higher accuracy (less frequent accidental commits, etc.) - I don't remembe…

Which GUI do you use?

Re: Oh shit, git: Getting myself out of bad situations

#404
post #123

Adopted a git GUI years ago and haven't looked back. I get looks sometimes, but I can't help but gloat when I can stage and unstage individual lines in less than a second. I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI. Takeaways: - My commit time is usually much faster than coworkers, with higher accuracy (less frequent accidental commits, etc.) - I don't remembe…

I use the git CLI. I do it for one reason. I know exactly what i'm doing on it. I have nothing to prove to anyone, I'm not trying to impress anyone with my "hacker" skillz. When I've tried GUI's, I'm not 100% sure what's going on under the covers. Sometimes they try to obfuscate things. While I'm probably not the worlds most advanced user, I know enough to know what I want to do, and how to do it. The CLI let's me do…

How about if someone made a GUI with a console at the bottom that showed the commands being executed along with results?

Re: Oh shit, git: Getting myself out of bad situations

#405
post #364

Earlier quoted context omitted.

This is so wrong. :) With git you exactly do not have to backup your local workspace, because it already is backed up in git. If it is committed, it is safe. You can go back to it. If you messed up your branch, just reset it to something that was good. No need to do manual backups.

Sure it's wrong if you know what you're doing. But that's not who the blog post is for. Sometimes it's okay to take liberties with good practices - especially when learning, or when the world is on fire and a push needs to happen now .

> or when the world is on fire and a push needs to happen now.

The unwanted reality we live in.

Re: Oh shit, git: Getting myself out of bad situations

#406

Earlier quoted context omitted.

Quick quiz, what does 'git checkout x/y' do? I am aware of users hitting at least 3 interpretations.

I'd say it changes your code to match that of a branch in your local copy of the repo.

It resets the file x/y, or checks out branch y of remote x, or checks out local branch x/y. I've had confused users manage to create al of these cases, and git is very unhelpful in explaining the difference between the three cases.

Re: Oh shit, git: Getting myself out of bad situations

#407

Adopted a git GUI years ago and haven't looked back. I get looks sometimes, but I can't help but gloat when I can stage and unstage individual lines in less than a second. I think anyone who uses the CLI is either trying too hard or hasn't realized the beauty of a git GUI. Takeaways: - My commit time is usually much faster than coworkers, with higher accuracy (less frequent accidental commits, etc.) - I don't remembe…

It doesn't have to be an exclusive or. I use the CLI for most things, but a GUI when it makes sense (like you mentioned, staging specific hunks). I find that for the most part, my CLI workflow is so straightforward I rarely get in an "oh shit" moment: git pull, git co -b featurebranch, a series of git ci -av, and a git push to open a pull request.

Re: Oh shit, git: Getting myself out of bad situations

#408
post #261

Earlier quoted context omitted.

You already have git-revert, for reverting commits without rewriting history.

You're misunderstanding the purpose i'm describing. Imagine 100 commits a day, maybe more. (I worked at a company that averaged 500 or more commits a day to the master branch. There were 1000 developers working in a monorepo). Some code is out in production, and suddenly we realize a specific commit is causing a problem. The idea here is to revert the commit as soon as you can, and then spend your time fixing it. Whe…

git revert is exactly the tool for the situation you are describing

Re: Oh shit, git: Getting myself out of bad situations

#409
post #127

Earlier quoted context omitted.

You're comparing git to vim in terms of ease of use...

That's actually a rather good comparison. Both have learning cliffs of doom[1]but once you've spent a few months with them they're arguably more powerful than the other options. They're usually fast to use but very hard to learn. I wouldn't say either one is easy though. [1] https://dementiagaming.files.wordpress.com/2010/08/learning_...

That's debatable. I don't think anyone has actually made any study which proves that git is superior to Mercurial or that vim is superior to Notepad++ or Sublime.

Re: Oh shit, git: Getting myself out of bad situations

#410

The fact web pages like this exist, and are popular, and make it to the top of Hacker News is all you need to know about git's ease-of-use and mental model. That Perforce and SVN don't get such things should also tell you something. (Which isn't to hate on git--it's a great tool.)

The SVN and P4 articles exists (just google for "svn mistakes" and "perforce p4 mistakes"), but either 1. nobody is sharing them to HN or 2. they do and nobody cares to vote them up.

Unrelated topic (falling cats), same logical fallacy: http://www.radiolab.org/story/102525-vertigo/ (Starting around 14:20)

Post reply on HN