File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
1010For a steady stream of TILs from a variety of rocketeers, checkout
1111[ til.hashrocket.com] ( https://til.hashrocket.com/ ) .
1212
13- _ 687 TILs and counting..._
13+ _ 688 TILs and counting..._
1414
1515---
1616
@@ -167,6 +167,7 @@ _687 TILs and counting..._
167167- [ Delete All Untracked Files] ( git/delete-all-untracked-files.md )
168168- [ Determine The Hash Id For A Blob] ( git/determine-the-hash-id-for-a-blob.md )
169169- [ Diffing With Patience] ( git/diffing-with-patience.md )
170+ - [ Dropping Commits With Git Rebase] ( git/dropping-commits-with-git-rebase.md )
170171- [ Dry Runs in Git] ( git/dry-runs-in-git.md )
171172- [ Excluding Files Locally] ( git/excluding-files-locally.md )
172173- [ Find The Initial Commit] ( git/find-the-initial-commit.md )
Original file line number Diff line number Diff line change 1+ # Dropping Commits With Git Rebase
2+
3+ I've been warned enough times about the potential dangers of `git reset
4+ --hard ...` that I always second guess myself as I type it out. Is it ` git
5+ reset --hard HEAD` or ` git reset --hard HEAD~ `?
6+
7+ If the working directory and index are clean, then there is another way to
8+ remove commits. A way that gives me more confidence about what exactly is
9+ being removed.
10+
11+ Doing an interactive rebase gives you a number of options. One of those
12+ options is ` d ` (which stands for ` drop ` ).
13+
14+ ```
15+ $ git rebase -i master
16+ ```
17+
18+ This pulls up an interactive rebase with all commits going back to what is
19+ on master -- great for when working from a feature branch.
20+
21+ ```
22+ pick 71ed173 Add Create A Stream From An Array as a reasonml til
23+ pick 80ac8d3 Add some clarity by distinguishing var names
24+ d 4f06c32 Add Data Structures With Self-Referential Types as a reasonml til
25+ d 01a0e75 Fix the name of this file
26+ ```
27+
28+ Adding ` d ` next to the commits you want to get rid of and saving will drop
29+ those commits. The great part is that there is zero ambiguity about which
30+ ones are being dropped.
31+
32+ h/t Jake Worth
You can’t perform that action at this time.
0 commit comments