mirror of
https://github.com/jbranchaud/til
synced 2026-01-03 23:28:02 +00:00
Add Dropping Commits With Git Rebase as a git til
This commit is contained in:
@@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
|
|||||||
For a steady stream of TILs from a variety of rocketeers, checkout
|
For a steady stream of TILs from a variety of rocketeers, checkout
|
||||||
[til.hashrocket.com](https://til.hashrocket.com/).
|
[til.hashrocket.com](https://til.hashrocket.com/).
|
||||||
|
|
||||||
_687 TILs and counting..._
|
_688 TILs and counting..._
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@@ -167,6 +167,7 @@ _687 TILs and counting..._
|
|||||||
- [Delete All Untracked Files](git/delete-all-untracked-files.md)
|
- [Delete All Untracked Files](git/delete-all-untracked-files.md)
|
||||||
- [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md)
|
- [Determine The Hash Id For A Blob](git/determine-the-hash-id-for-a-blob.md)
|
||||||
- [Diffing With Patience](git/diffing-with-patience.md)
|
- [Diffing With Patience](git/diffing-with-patience.md)
|
||||||
|
- [Dropping Commits With Git Rebase](git/dropping-commits-with-git-rebase.md)
|
||||||
- [Dry Runs in Git](git/dry-runs-in-git.md)
|
- [Dry Runs in Git](git/dry-runs-in-git.md)
|
||||||
- [Excluding Files Locally](git/excluding-files-locally.md)
|
- [Excluding Files Locally](git/excluding-files-locally.md)
|
||||||
- [Find The Initial Commit](git/find-the-initial-commit.md)
|
- [Find The Initial Commit](git/find-the-initial-commit.md)
|
||||||
|
|||||||
32
git/dropping-commits-with-git-rebase.md
Normal file
32
git/dropping-commits-with-git-rebase.md
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
# Dropping Commits With Git Rebase
|
||||||
|
|
||||||
|
I've been warned enough times about the potential dangers of `git reset
|
||||||
|
--hard ...` that I always second guess myself as I type it out. Is it `git
|
||||||
|
reset --hard HEAD` or `git reset --hard HEAD~`?
|
||||||
|
|
||||||
|
If the working directory and index are clean, then there is another way to
|
||||||
|
remove commits. A way that gives me more confidence about what exactly is
|
||||||
|
being removed.
|
||||||
|
|
||||||
|
Doing an interactive rebase gives you a number of options. One of those
|
||||||
|
options is `d` (which stands for `drop`).
|
||||||
|
|
||||||
|
```
|
||||||
|
$ git rebase -i master
|
||||||
|
```
|
||||||
|
|
||||||
|
This pulls up an interactive rebase with all commits going back to what is
|
||||||
|
on master -- great for when working from a feature branch.
|
||||||
|
|
||||||
|
```
|
||||||
|
pick 71ed173 Add Create A Stream From An Array as a reasonml til
|
||||||
|
pick 80ac8d3 Add some clarity by distinguishing var names
|
||||||
|
d 4f06c32 Add Data Structures With Self-Referential Types as a reasonml til
|
||||||
|
d 01a0e75 Fix the name of this file
|
||||||
|
```
|
||||||
|
|
||||||
|
Adding `d` next to the commits you want to get rid of and saving will drop
|
||||||
|
those commits. The great part is that there is zero ambiguity about which
|
||||||
|
ones are being dropped.
|
||||||
|
|
||||||
|
h/t Jake Worth
|
||||||
Reference in New Issue
Block a user