In the end i end up committing function by function
Do not forget you could rather "git add" function by function, making only one commit:
- once all the functions are written or fixed for a given task
- or once you realize the current function is too large/complicated to be part of a commit any time soon: you can then commit what is currently "on stage" ("git added"), which would not include your current modifications in the working directory.
Then, the number of commits can be related to the purpose of the branch:
- local branch: go crazy, commit anytime you want
- "public" branch (one that you will push):
- for a local repository (for selected group of people): you could regroup at least the very small "intermediate" commits
- for a public repository (for all developers, or other projects to see): you can make an interactive rebase in order to regroup your commit by "activity" or "task" in order to make those more readable.
In short, "publication considerations" can, in a DVCS (as in "Distributed"), guide you as to make the proper number of commits for the right reasons.