Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you avoid that people forget to run 'git push'?

Tags:

git

While evaluating the advantages and disadvantages of moving our Subversion-based repository over to Git, one interesting question came up.

Even though that we're all quite fond of Git, it might happen that some developer (or a team of developers) forgets to push a feature/bugfix onto the repository from which the packages are built.

I'm sure this concern was raised in other software development teams already, I wondered how you tackled this problem.

like image 868
Frerich Raabe Avatar asked Oct 16 '09 15:10

Frerich Raabe


1 Answers

I agree that ideally you can fix this simply by trying to give plenty of reminders. A few miscellaneous thoughts:

  • Anything that reinforces the distributed version control idea will help make people think of this more naturally. For example, I favor a workflow that includes using local topic branches and amending/rebasing commits until they're exactly what I want. If you teach how to do this, it becomes obvious that these are things done in your own area. As developers become more aware that their repo is different from the central one, remembering to push will get much easier.

  • If you're on your master branch (or any other branch that tracks a branch on origin), git-status will give you reminders like "Your branch is ahead of 'origin/master' by 1 commit." You'll also see this when you check out master.

  • You could, if you really wanted, write a post-commit hook that simply notifies the user how far they've diverged from origin. There are a lot of ways to approach this, depending on your workflow - perhaps just duplicate that status message, perhaps find the oldest commit on the current branch that isn't in origin so you can let them know how long it's been... Note that including hooks with the repository isn't trivial: .git/hooks is not tracked, so you have to symlink either the directory or the hooks inside it into the repo. This can be automated by a setup script, though, so it's not too bad!

like image 174
Cascabel Avatar answered Nov 04 '22 17:11

Cascabel