Member-only story
Six Rules for Good Git Hygiene
How to be a team player with your commits, pushes, and pulls

Git is the dominant source control system out there—the de facto tool for software developers. It’s used to manage teams working together in a company, or to run open-source projects where the developers are scattered all over the world.
Getting used to working on a team is one of the first things a new developer has to learn. Working on a shared codebase is very much part of that. As a result, Git is an essential tool in a new developer’s tool belt. Learning how to manage your local and remote repositories properly is a crucial skill for a team member to master.
Here are six tips to help make sure that you are a good Git citizen, and that you do your part to keep your team’s code repository as clean and conflict-free as possible.
As a side note, I’m assuming that you and your team have selected some form of workflow for your Git repository. If you haven’t done so, then much of what I say below won’t make sense. And if you haven’t yet picked a workflow, I strongly recommend that you do so immediately.
Always Pull Before a Push
This is a bedrock rule. Before you try to push code out to the repository, you should always pull all the current changes from the remote repository to your local machine. Doing so will ensure that your local copy is in sync with the remote repository. Remember, other people have been pushing to the remote copy, and if you push before syncing up, you could end up with multiple heads or merge conflicts when you push.
By default, Git will not allow you to push changes onto a branch that has remote commits. You can turn this feature off, but it’s not recommended.
Pull frequently
On large teams, the central repository will continuously be changing. You should endeavor to keep your local machine as close to the remote repository as possible. The way to do that is to pull all the changes on the remote server to your local copy. You can do this as often as you like, and should do it frequently — at least once a day if not more.