Live data from Hacker News

Some bad Git situations and how I got myself out of them

ohshitgit.com

191–200 of 352 posts

Re: Some bad Git situations and how I got myself out of them

#191

I can't believe no one has responded yet with "use a GUI". After gaining a basic understanding of how branches and merges work, and I do mean basic , I've never been able to screw up a local repo with a GUI client enough that I haven't been able to recover with the same GUI tools. I understand that people need to know how to use their tools, but for git most people can get away with the very basic usage that GUIs pro…

I've never really screwed it up that badly using the command line either. I don't know what these people are trying to do that they constantly mess up their repository so bad they can't fix it. Perhaps being too obsessed with having a perfect commit history.

Re: Some bad Git situations and how I got myself out of them

#192

Well, there are many more situations you can get into. Like cherry picking, force pushing, merge --no-commit, rebasing... almost any operation can end up going wrong. Just pay attention.

But he has the final solution to any git problem:

  cd ..
  sudo rm -r fucking-git-repo-dir
  git clone https://some.github.url/fucking-git-repo-dir.git

Re: Some bad Git situations and how I got myself out of them

#193
One thing not covered very well was what to do if you push to origin. My favourite way to fix this: use git revert to create an exact opposite commit to your bad commit.

  git revert 
  git push
It leaves a history of the mistake, for better or worse, but it does undo the mistake on origin.

Re: Some bad Git situations and how I got myself out of them

#195
post #176

Earlier quoted context omitted.

sorry... you come across as a git-sheep. (getting down-voted for it, but someone has to say it)

I'm prepared to give you a lot of examples (which other people might value differently). From the unfortunate consequences of the 'branches are files (and therefore tags are easily mutable by default and surprisingly hard to pin down)' to usual "I just committed, why does 'svn log' not show that?", to git bisect, to git clean and the stubbornness with which svn refuses to even consider implementing that.

that sounds like process-issues... not SVN issues.

tags should not be committed to... end-of-story.

as for 'svn-log not showing commits'... I've never heard of that one in the last decade of using it... I'm genuinely interested in how that came about.

Re: Some bad Git situations and how I got myself out of them

#196
post #161

One of the nice workflows that's already built in to the git command line tools is this one. When you're working on a branch and realise that a commit you made a few commits back has a mistake in it: # Make correcting change git commit --all --fixup= # Continue working on branch, then at some point git rebase --interactive --autosquash The --fixup option creates commits with subjects formatted like 'fixup! previous c…

Even better in combination with the `:/grep` syntax that allows you to specify the commit by grepping the commit messages, prefering more recent commits: `git commit --all --fixup ':/implement some feat'`.

Re: Some bad Git situations and how I got myself out of them

#197
post #193

One thing not covered very well was what to do if you push to origin. My favourite way to fix this: use git revert to create an exact opposite commit to your bad commit. git revert git push It leaves a history of the mistake, for better or worse, but it does undo the mistake on origin.

Why not git commit to a different branch? You revert and push it anyway, right! I guess, for better or worse, it worth your while to keep a mistake, not two of them.

Re: Some bad Git situations and how I got myself out of them

#198

Earlier quoted context omitted.

Have you tried GitKraken? https://www.gitkraken.com/ Seems like there's a glut of these apps of late—not that I'm complaining! :-)

It's built on electron, though.

Which, as far as I know, works on Linux.

Re: Some bad Git situations and how I got myself out of them

#200

Earlier quoted context omitted.

I don't know how it compares to GitUp, but SmartGit works on Linux, Windows, and macOS. I use it on all three platforms and recommend it highly. See my other comment in the subthread for more thoughts about it.

It's not free software though.

True, SmartGit is not open source or free-as-in-speech. It is free-as-in-beer if you use it for open source or noncommercial purposes. I use it for commercial projects and didn't blink at their price - it's paid for itself many times over.
Post reply on HN