---
title: "Format Swift with a Git Commit Hook"
url: https://daily.dev/posts/format-swift-with-a-git-commit-hook-4gmlicjcc
source_url: https://useyourloaf.com/blog/format-swift-with-a-git-commit-hook/
type: article
source: "Use Your Loaf"
published: 2025-11-24T14:49:22.131Z
updated: 2025-11-24T14:49:41.418Z
tags: ["ios", "git", "swift", "xcode"]
reading_time: 3
upvotes: 0
comments: 0
language: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Format Swift with a Git Commit Hook

**[Use Your Loaf](https://daily.dev/sources/useyourloaf)** · 3 min read · 0 upvotes · 0 comments

## Summary

Learn how to automatically format Swift code on every Git commit using swift-format and pre-commit hooks. The guide covers configuring swift-format with custom settings, creating a bash script that formats staged Swift files before committing, and installing the hook in your Git repository. The approach ensures consistent code formatting across your project without manual intervention.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://useyourloaf.com/blog/format-swift-with-a-git-commit-hook/>

## Similar posts on daily.dev

- [Using Git Pre-Commit Hooks](https://daily.dev/posts/using-git-pre-commit-hooks-hwaqvr4rm) · Scott's Weblog · 1 upvotes · 0 comments

---

Tags: [#ios](https://daily.dev/tags/ios), [#git](https://daily.dev/tags/git), [#swift](https://daily.dev/tags/swift), [#xcode](https://daily.dev/tags/xcode)

[View this post on daily.dev](https://daily.dev/posts/format-swift-with-a-git-commit-hook-4gmlicjcc)
