Live data from Hacker News

Oh shit, git: Getting myself out of bad situations

ohshitgit.com

121–130 of 520 posts

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

#121

Earlier quoted context omitted.

I'm planning on making a hard push for git on the team I just joined (that isn't using any VCS). This and OP are going in my bookmarks.

> I'm planning on making a hard push for git on the team I just joined You mean a force push. `git push --force` is one of my favorite commands. I've aliased `git yolo` to `git push --force --no-verify`.

--force-with-lease is usually the better option; it makes sure nobody pushed anything since the last time you fetched from the remote.

If they have, you can fetch, see if you still want to overwrite that branch, and if so run it again.

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

#122

My last git mistake was pretty terrifying. I decided to try and go back to an old commit on a project on my local machine after about a days work. Somehow I ended up making the commit I wanted to revert to a new branch, then somehow tagged that branch with the name of the commit making git get angry and decide that branch wasn't valid. Then continuing in my ignorance I reset to that branch and tried to checkout only…

Git is not a backup! Had you had one, you could have had your mind at ease.

Ya I realize this now. I usually keep backups. I don't know why I haven't been on this project. I'm using git properly now with proper backups for the project. Though everything's still on the local machine, it's better than the setup I had. I chose to take it as a warning to sort that shit out.

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

#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 it. The GUI get's in my way.

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

#124

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…

My biggest issue with a GUI is that most that I've seen introduce new terms for various stuff, e.g. "sync" in VS Code, or "revert commit" (in Source Tree maybe?) — there's no Git command called "sync" or "revert", so I'm not immediately sure what they do. In a CLI I know exactly what's happening. That's just my opinion though. If people feel comfortable working in a GUI all the more power to them.

> no Git command called ... "revert"

Maybe not in the way Source Tree uses it, but there certainly is[1]! I've had to use it a few times.

> git-revert - Revert some existing commits

[1] https://git-scm.com/docs/git-revert

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

#125

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…

What GUI do you recommend? My experience has been that GUIs are the easiest and fastest way to make a mess that can't be corrected without dropping to CLI or re-cloning. (I'm looking at you SourceTree). I've long recommended that everyone who uses git know how to use the CLI even if they don't use it regularly.

SourceTree by Atlassian ... free.

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

#126

Earlier quoted context omitted.

What GUI do you recommend? My experience has been that GUIs are the easiest and fastest way to make a mess that can't be corrected without dropping to CLI or re-cloning. (I'm looking at you SourceTree). I've long recommended that everyone who uses git know how to use the CLI even if they don't use it regularly.

Magit in emacs. Probably one of the killer applications for emacs.

I'd hesitate to call Magit a git GUI though.

If we take Ranger for example, who calls itself the "CLI file manager", then Magit is rather a "git CLI".

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

#127
post #20

The very existence of such guides tells us a lot about how easy to use Git is :)

Name me any software that doesn't need a guide like this. like, how do you even exit vim? You need a guide for that. Or to get it closer to git / this guide, how do you undo / redo?

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

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

#128

My last git mistake was pretty terrifying. I decided to try and go back to an old commit on a project on my local machine after about a days work. Somehow I ended up making the commit I wanted to revert to a new branch, then somehow tagged that branch with the name of the commit making git get angry and decide that branch wasn't valid. Then continuing in my ignorance I reset to that branch and tried to checkout only…

Git is not a backup! Had you had one, you could have had your mind at ease.

Pushing to a remote is a backup. Gitlab offers private repositories for free.

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

#129

A git off my lawn moment: Every time I see someone complaining because they have to dive into the reflog to fix their own mistake, all I can hear is "I was operating my table saw without using a push stick and can't understand why I lost a thumb". Friends don't let friends (especially those who don't learn how to use their tools) rewrite shared git history. If you don't understand rebase, amends, etc can do to your (…

rebase can be dangerous, but so productive. I think it's important to teach new devs how to properly use it. Especially if you're working in a continuous deployment environment, where you may need to quickly revert something.

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

#130

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 work very well on a cli. I can do partial adds faster than you and don't had any 'oh shit' moments for a few years.

I do not care if someone is using a gui.

My takeaway: - If i can use git on an cli, i can use git on any server with an cli. I do need this for when i use git on my ansible maschine or on my home media server or when doing something with build infrastructure (jenkins -> git -> cli)

Post reply on HN