File tree Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Expand file tree Collapse file tree 2 files changed +31
-1
lines changed Original file line number Diff line number Diff line change @@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
10
10
11
11
For a steady stream of TILs, [ sign up for my newsletter] ( https://tinyletter.com/jbranchaud ) .
12
12
13
- _ 1016 TILs and counting..._
13
+ _ 1017 TILs and counting..._
14
14
15
15
---
16
16
@@ -213,6 +213,7 @@ _1016 TILs and counting..._
213
213
214
214
- [ Accessing a Lost Commit] ( git/accessing-a-lost-commit.md )
215
215
- [ Amend Author Of Previous Commit] ( git/amend-author-of-previous-commit.md )
216
+ - [ Auto-Squash Those Fixup Commits] ( git/auto-squash-those-fixup-commits.md )
216
217
- [ Caching Credentials] ( git/caching-credentials.md )
217
218
- [ Change The Start Point Of A Branch] ( git/change-the-start-point-of-a-branch.md )
218
219
- [ Checking Commit Ancestry] ( git/checking-commit-ancestry.md )
Original file line number Diff line number Diff line change
1
+ # Auto-Squash Those Fixup Commits
2
+
3
+ As a fan of [ atomic commits] ( https://dev.to/jbranchaud/atomic-commits-4hk2 ) , I
4
+ sometimes find myself with some changes that are ready to stage that belong on
5
+ an earlier commit. If it is the immediately previous, I'll do an ` --amend ` . For
6
+ anything further back than that, I've come to love the use of `git commit
7
+ --fixup <SHA >`.
8
+
9
+ Once one or more _ fixup_ commits are on the current branch, they'll need to be
10
+ _ squashed_ into the commits for which they've been targeted. This calls for a
11
+ ` git rebase ` .
12
+
13
+ Git knows how to squash fixup commits into the correct place, but you have to
14
+ tell it to do so automatically. You can do that one of two ways.
15
+
16
+ You can either include the ` --autosquash ` flag each time you rebase:
17
+
18
+ ``` bash
19
+ $ git rebase -i --autosquash
20
+ ```
21
+
22
+ Or you can tell Git to always autosquash in your ` ~/.gitconfig ` :
23
+
24
+ ```
25
+ [rebase]
26
+ autoSquash = true
27
+ ```
28
+
29
+ See the section on ` --autosquash ` in ` man git-rebase ` for more details.
You can’t perform that action at this time.
0 commit comments