---
title: "Discussion on \"How To Format Only Staged Files With Spotless\" | Hashnode"
description: "Discussion on \"How To Format Only Staged Files With Spotless\". As a developer, you know that keeping your code clean and consistent is crucial for the success of any project. One tool that can help you achieve this is Spotless, a powerful code formatting plugin f"
url: "https://hashnode.com/posts/how-to-format-only-staged-files-with-spotless/6436ccfbcf248f86fdaa2b11"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [How To Format Only Staged Files With Spotless](https://blog.joetr.com/how-to-format-only-staged-files-with-spotless?utm_source=hashnode&utm_medium=feed)

As a developer, you know that keeping your code clean and consistent is crucial for the success of any project. One tool that can help you achieve this is Spotless, a powerful code formatting plugin f

Apr 12, 2023 · 3 min read · blog.joetr.com  
Updated Apr 29  
Read the article

-   [#git](https://hashnode.com/tag/git)
-   [#formatting](https://hashnode.com/tag/formatting)

## Written by

[Joe Roskopf](https://hashnode.com/@joetr)

@joetr · Minneapolis, MN

  
[View profile](https://hashnode.com/@joetr)

Principal Android Engineer @ Nike

Hey! I’m Joe! I’m an Android developer who is passionate about the human side of software development.

## Responses 1

Markdown supported · ⌘↵ to post

[Ahmad Wehbe](https://hashnode.com/@ahmadwehbe)

[Nov 18, 2024](https://hashnode.com/posts/how-to-format-only-staged-files-with-spotless/6436ccfbcf248f86fdaa2b11/comment/673b1b9b240c50807a5e85b7)

Hey Joe. This runs spotlessApply on all the project. but it only adds and commits staged files. Is there a way to run spotless only on staged files?

[Joe Roskopf](https://hashnode.com/@joetr)

[Nov 18, 2024](https://hashnode.com/posts/how-to-format-only-staged-files-with-spotless/6436ccfbcf248f86fdaa2b11/comment/673b1b9b240c50807a5e85b7#reply-673ba119be2177a59c6988c8)

Hey! This definitely assumes the rest of the project already has spotless applied to it.

You could consider modifying the script / your project with the following: [github.com/diffplug/spotless/tree/main/plugin-gra…](https://github.com/diffplug/spotless/tree/main/plugin-gradle#ratchet)
