I'm just starting with git and although I know its theory very well, commands and others, it took me a while to get used to it in practice...
Let's say I'm in a project and I'm developing the navigation bar. Should I commit when the bar is completely ready or at each step of the construction of the navigation bar?
make commits of type: Added navigation bar
or of the type: - List bar styles - Established bar links etc etc. Thank you for your answers !
In general, and not specifically in Git, it is always recommended to make consecutive commits to have your changes versioned and available in source code control.
Specifically in Git and answering the specific question you've asked:
Assuming the following:
My recommendation is the following:
push
it through what is known as squashIn the end, the most important thing to remember is what @Kristian Damian mentions in his answer: Basically that 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
As Alvaro comments, it is more a question of styles, but in the best practices of git they invite you to commit
temprano y seguido
One of the advantages that you would obtain by committing often is the possibility of going back to several previous states in case of a difficult to track bug, but it is important to take into account that you should establish minimum rules for the commit, such as:
Basically it is about being a good citizen with the rest of the team members or that you facilitate the cloning of your branch