What semantic commit type is better to use, when I remove a feature: feat
, refactor
or something else?

- 24,552
- 19
- 101
- 135

- 2,088
- 3
- 23
- 32
5 Answers
you should use refactor
,
- feat: introduces a new feature to the codebase
- fix: patches a bug in your codebase
- refactor: A code change that neither fixes a bug nor adds a feature
you can refer to angular/CONTRIBUTING Commit Message Guidelines

- 4,279
- 3
- 37
- 40
-
If I delete a unit test project + its source code, is that `test:`? Or still `refactor:`? – void.pointer Apr 27 '22 at 14:41
-
8If refactor means refactoring, it would be wrong to use it. Refactoring means [improving the code without modifying the existing functionality](https://www.sciencedirect.com/topics/computer-science/refactoring). – Ferdinand Prantl May 17 '22 at 15:25
-
@void.pointer, I use feat, fix and refactor for changes made in the shipping code. I use test for any change in the tests, docs for any change in the documentation. – Ferdinand Prantl May 17 '22 at 15:27
-
5Refactor is for changes that _do not introduce any changes in the feature set_. Or system behavior. It is written as "adds a feature", but the code does not have to strictly have more bytes than before. From the product owner's perspective, sometimes removing things, even (old?) features, is a (new) feature. Busineses change with time, so do features. 3 years ago, I added "handle SWIFT transfers to Russia". It was a new feature. Lately I removed this code, because "ignore SWIFT transfers to Russia" is the new top-scored requirement. Removing code turned out to add a feature of the system. – quetzalcoatl Sep 02 '22 at 17:36
-
2This is the correct answer: https://stackoverflow.com/a/73944665/930998 – Adam Gerthel May 24 '23 at 11:37
By definition, it is refactor
, since:
refactor: A code change that neither fixes a bug nor adds a feature
Removing a feature is certainly a code change, and it neither fixes a bug nor adds a feature.
However, people usually have an assumption that refactor tends to not introduce breaking changes. And removing a feature tends to always break the API, since a feature is removed from the API, and this breaks all existing system depending on that feature.
What about other types? Absence of a feature itself may be considered as a feature. For example, if someone dislike the idea of password login (it is annoying to input a password every time to login), then they may consider not having the feature of password login is a feature. Thus removing a feature can be considered as adding an new feature. At the same time, if absence of a feature itself may be considered as a feature, than the existence of that feature may be considered as a bug. So removing a feature may be considered as fixing a bug. Thus removing a feature is both feat
and fix
.
Alternatively, we can pretend that the problem does not exist. A well designed library should not have an unwanted feature. And since other libraries and applications may depend on this feature, so features should never be removed. But this ideal principle does not apply to every library.
So my suggestion is giving this type of commit a new name.

- 28,682
- 5
- 48
- 60
-
1It may not `fix` a bug, but it does `fix` some *issue* (e.g. improves UI, or removes obscure feature requiring too much code complexity to support). So, if one doesn't want to introduce a new prefix, I think `fix` is a good default. On the other hand, there is also `refactor!: ...` with an *exclamation mark* to denote breaking changes. – Mateen Ulhaq Mar 15 '22 at 04:08
-
2Your answer starts with an incorrect statement, followed by a long explanation why it's incorrect, but I think most ppl that come here will only read the first line... – Adam Gerthel May 24 '23 at 11:36
-
1Removing a feature is the same as adding a feature but with negative sign. – Fernando Jun 09 '23 at 11:08
Use feat when you add or remove a feature.
According to wikipedia, "code refactoring is the process of restructuring existing computer code without changing its external behavior".
If you remove a feature you change code behavior so it can not be a refactor.

- 1,013
- 2
- 10
- 23
Exclamation marks can be used to denote breaking changes. Removing a feature is a breaking change. Thus, there is refactor!
:
refactor!: a BREAKING CHANGE that neither fixes a bug nor adds a feature

- 24,552
- 19
- 101
- 135
Use refactor
,because you reconstruction your code. There is a reference about Git Commit Msg for you

- 85
- 3
- 12
-
2Whilst this may theoretically answer the question, [it would be preferable](//meta.stackoverflow.com/q/8259) to include the essential parts of the answer here, and provide the link for reference. – Tim Diekmann Jun 05 '18 at 09:12