File tree Expand file tree Collapse file tree 1 file changed +7
-14
lines changed
book/07-git-tools/sections Expand file tree Collapse file tree 1 file changed +7
-14
lines changed Original file line number Diff line number Diff line change @@ -310,22 +310,15 @@ pick 461cb2a This commit is OK
310
310
drop 5aecc10 This commit is broken
311
311
----
312
312
313
- [CAUTION]
314
- ====
315
- Do not delete/drop a commit that other commits depend on!
316
- It's a bad idea to drop the first commit in the `rebase -i` script list.
317
- The following commits depend on the first commit being present, as the root of all changes that follow.
318
- ====
313
+ Because of the way Git builds commit objects, deleting or altering a commit will cause the rewriting of all the commits that follow it.
314
+ The further back in your repo's history you go, the more commits will need to be recreated.
315
+ This can cause lots of merge conflicts if you have many commits later in the sequence that depend on the one you just deleted.
319
316
320
- Avoid doing this:
321
- [source,console]
322
- ----
323
- drop 5aecc10 This commit is broken
324
- pick c6be4c9 This commit is OK but depends on changes made in 5aecc10
325
- ----
317
+ If you get partway through a rebase like this and decide it's not a good idea, you can always stop.
318
+ Type `git rebase --abort`, and your repo will be returned to the state it was in before you started the rebase.
326
319
327
- Git will complain about the broken state, and ask you to resolve the conflicts manually .
328
- You can also just back out of the rebase by using `git rebase --abort` .
320
+ If you finish a rebase and decide it's not what you want, you can use `git reflog` to recover an earlier version of your branch .
321
+ See <<ch10-git-internals#_data_recovery>> for more information on the `reflog` command .
329
322
330
323
[NOTE]
331
324
====
You can’t perform that action at this time.
0 commit comments