Do you push every single commit?

rynd picture rynd · May 12, 2012 · Viewed 31.4k times · Source

I would like, if someone could give me more detail in working with git and remote repositories. I haven't worked with remote repositories, yet.

To the local repository you commit smaller changes that may not be too world-shattering. What is pushed to the remote repository? Every local commit? Or the overall-work that was done, which is then merged with overall-works of others? I think the log of the remote repository must be confusing, if everyone pushes every commit.

Answer

acattle picture acattle · May 12, 2012

Pushing and Pulling from the remote repository isn't quite as important as your local commits. Typically pushing and pulling a few times a day is sufficient. Like @earlonrails said, more frequent pushes means less likelihood of conflicting changes but typically it isn't that big a deal.

Think of it this way, by committing to your local repository you are basically saying "I trust this code. It is complete. It runs. I have tested it. I am ready for other people to see it." If you want to push to the remote repository after every commit, that's fine but as long as you do it on a regular basis it doesn't really matter.

Local repositories are about tracking your changes to protect the work you do. Remote repositories are for distributing the work to all your teammates and tracking everyone's changes. Your teammates need access to your code, but usually it isn't urgent and can wait until the end of the day or whenever you feel like pushing.