Using ‘git sync’ to automate common Git commands

Posted by & filed under Uncategorized.

At Brightrock Games about 5 of us actively use Git hourly to commit and pull work all day from the same branch. Doing this often means that every time you want to do a git pull or push, there are several manual steps you have to take to stash any outstanding changes you haven’t yet got around to committing (Or any unnecessary trash Unity makes) so you can then pull rebase if there is something upstream then finally push. Its an annoyance that wastes a few minutes every few hours.

Git best practices will suggest that each developer works in their own branch until they’re ready to merge, but in practice when the whole team is rapidly pumping out bug fixes and improvements its just easier to be working together.

To improve our workflow I have created a git alias that performs a git stash -> git pull –rebase -> git push -> git unstash called git sync.

On a command-line paste in the following to create a global git alias:

That’s it.
For reference here is the non-minified script code:


Leave a Reply