Q:

How to ensure a successful compile using Git

I'm just starting out with Git but haven't actually used it in a team. The biggest question I have yet to answer is how to use Git in such a way to ensure that my main branch compiles successfully 100% of the time. Realistically I know that that is not possible.
From what I understand, each developer grabs a copy of the repository, makes changes locally and periodically commits changes. Multiple branches can end up getting created throughout the week but once or twice a week I'd like to have a compile on my main branch.
I assume that each developer is responsible for merging branches into the main branch and that the project leader performs a compile on the code along the main branch. Is this the general flow of how things typically work in a team collaborating with Git? Does the project leader have to notify all the other developers to make all their commits by say 3:00 pm on Wednesday because a compile will be made at that time? or does the project leader not need to tell developers when to perform their final commits and just assumes that the main branch is always in a state that it will compile without problems?
I guess my difficulty in understanding how to use Git effectively is how all developers remain synchronized by the time you want to perform a major compile once or twice a week.

A:

There are predefined workflows that can help you to get inspiration for a good git workflow. git-flow is the most well known.
It doesn't mean you have to do it exactly like that, but it can give you guidance how to implement a release branch, how to deal with hot-fixes and more.
Another well known workflow is github flow, which uses a much simpler approach. It just has a development branch, and everyone works on feature branches, which get merged back in when ready. They also use continuous deployment, so they get rapid feedback when a build breaks.

