Live data from Hacker News

Oh shit, git: Getting myself out of bad situations

ohshitgit.com

11–20 of 520 posts

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

#12
post #9

Is it just me or did http://ohshitgit.com/#accidental-commit-master forget to checkout master before calling reset?

Creating a branch doesn't check it out by default. To do both at once, it's either "checkout -b" or "branch -c", I forget which because it's "b c" in Magit.

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

#14
post #9

Is it just me or did http://ohshitgit.com/#accidental-commit-master forget to checkout master before calling reset?

It's still on master because `git branch` just creates and doesn't do checkout.

(Which is why I've almost exclusively switched to `git checkout -b ` for creating. How often do I want to create but not switch to the branch?)

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

#15

If this is a guide for beginners, there should be (more?) warnings not to do history rewriting operations on commits that have already pushed.

From the disclaimer at the bottom: > This site is not intended to be an exhaustive reference, nor is it a beginner's tutorial.

It may not be intended to be a beginner's tutorial, but it is. Someone who needs to be told about `git commit --amend` and `git diff --staged` also needs to be warned about rewriting history that has been shared with others.

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

#16
In three years of using git I believe there is a single bad command that I could not undo: `git checkout -- somefile` The second worst thing I did is losing a commit in a `git rebase -i` but I was able to find it back with `git reflog`. Which makes me think that git is really well designed.

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

#17
post #10

If this is a guide for beginners, there should be (more?) warnings not to do history rewriting operations on commits that have already pushed.

Why is recovering from an upstream rebase considered more problematic than recovering from merge conflicts?

Who said anything about recovering. First we'll have to determine if upstream is supposed to be used in a rebase workflow or a merge workflow.

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

#18
post #9

Is it just me or did http://ohshitgit.com/#accidental-commit-master forget to checkout master before calling reset?

Creating a branch doesn't check it out by default. To do both at once, it's either "checkout -b" or "branch -c", I forget which because it's "b c" in Magit.

Ah, I figured I was missing something.

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

#19
post #14
post #9

Is it just me or did http://ohshitgit.com/#accidental-commit-master forget to checkout master before calling reset?

It's still on master because `git branch` just creates and doesn't do checkout. (Which is why I've almost exclusively switched to `git checkout -b ` for creating. How often do I want to create but not switch to the branch?)

Apparently the default behavior is for people who just like to know it's there ;)
Post reply on HN