Hacker News new | ask | show | jobs
by dundarious 1457 days ago
The steps I see on the website are:

  git branch some-new-branch-name
  git reset HEAD~ --hard
  git checkout some-new-branch-name
Which is correct, assuming master is already checked out.

0. prior state is that we're on master and have committed something that should have been on a branch

1. create a new branch that is identical to master (i.e., contains the commit) -- note this does NOT checkout the new branch (`git checkout -b some-new-branch-name` would do that)

2. reset current branch (master) to point at the commit before (i.e., strips the commit from master)

3. checkout the new branch to continue work there

At the end, master doesn't contain the commit anymore, and the new branch does. It's all correct.