Skip to content

Commit 47512b4

Browse files
committed
this just is not true
1 parent aa85ed5 commit 47512b4

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

book/07-git-tools/sections/advanced-merging.asc

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -493,10 +493,10 @@ There are two ways to approach this problem, depending on what your desired outc
493493
===== Fix the references
494494

495495
If the unwanted merge commit only exists on your local repository, the easiest and best solution is to move the branches so that they point where you want them to.
496-
In most cases, if you follow the errant `git merge` with `git merge --abort`, this will reset the branch pointers so they look like this:
496+
In most cases, if you follow the errant `git merge` with `git reset --hard HEAD~`, this will reset the branch pointers so they look like this:
497497

498-
.History after `git merge --abort`
499-
image::images/undomerge-reset.png[History after `git reset --merge`.]
498+
.History after `git reset --hard HEAD~`
499+
image::images/undomerge-reset.png[History after `git reset --hard HEAD~`.]
500500

501501
We covered `reset` back in <<_git_reset>>, so it shouldn't be too hard to figure out what's going on here.
502502
Here's a quick refresher: `reset --hard` usually goes through three steps:
@@ -506,8 +506,6 @@ Here's a quick refresher: `reset --hard` usually goes through three steps:
506506
. Make the index look like HEAD.
507507
. Make the working directory look like the index.
508508

509-
In the case of `git merge --abort`, Git is actually running a `git reset --merge` and when doing so, Git is extra careful with steps 2 and 3 to preserve any changes you've made in the working directory or the index, but otherwise works as though this were a `--hard` reset.
510-
511509
The downside of this approach is that it's rewriting history, which can be problematic with a shared repository.
512510
Check out <<_rebase_peril>> for more on what can happen; the short version is that if other people have the commits you're rewriting, you should probably avoid `reset`.
513511
This approach also won't work if any other commits have been created since the merge; moving the refs would effectively lose those changes.

0 commit comments

Comments
 (0)