RSS

GIT: push every commit immediately to origin

17 Dec

If I am working not on my primary PC I sometimes forget to push commits to the origin remote. Therefore next day I am in company I miss commits that are local on the other PC. To avoid that problem I wrote a git-hook that pushes every commit instantly to the origin-remote.

For this you need to create the file post-commit with following content

#!/bin/sh
#With this git-hook every commit is immeditely pushed to origin

branch=$(git rev-parse --abbrev-ref HEAD)
echo Pushing commit to origin/$branch
git push -u origin $branch

Save the file to the .git\hooks directory. Now after each git commit the commit is pushed to the remote.

Advertisements
 
Leave a comment

Posted by on December 17, 2014 in Git

 

Tags:

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: