Generally, and not specifically in Git, it is always advisable to make repeated commits to have your versioned changes available in the source control.
Specifically in Git and answering the specific question you have asked:
Assuming the following:
You have an assigned task whose specification is to create a navigation bar
You're working on a topic branch (also called feature branch)
My recommendation is this:
- If you feel comfortable and confident that you can deliver the corresponding changes to the entire specification without problems since the task is not very complex, then a single commit will suffice.
- If the task is too complex, I would recommend proposing to divide the task into several subtasks so that you can associate each particular step of the construction of for example the navigation bar with a specific commit.
- If the task is simple however you consider that it is better for you to perform several commits for whatever reason, for example because you want to understand the changes better or it seems more orderly, then do it that way, there is no problem. If in any case there was a policy of a checkin per task or if you later regret it and consider that you have done many checkins for something very simple you always have the possibility of joining them in one before doing
push
through what is known as < a href="http://git-scm.com/docs/git-rebase#_interactive_mode"> squash
In the end the most important thing to remember is what @Kristian Damian mentions in his answer: Basically, each checkin must contain changes that are functionally complete without breaking the code, unit test or build process that you have established.
The rest can be very subjective and depends on each case and each person