GitHub can't sync “pre-receive hook declined”

For my Makerfaire .NET Microframework embedded work I’ve been using the wonderful Git integration within Visual Studio. For my repository, I’ve been using GitHub as I don’t mind it being public.

It has been a great experience so far, as I’ve been brought up on Visual Source Safe then Team Foundation Server, the way Git works has taken me some time to get used to, but the integrated tools has made the learning easier.

image

The other day I put some documentation into my project, one file was a Microsoft Publisher file that was extremely large as it held the graphics for my printed displays at the faire. I innocently committed the files into my local repository, then tried to push it to GitHub. I got the

“pre-receive hook declined”

Error when trying to sync. It seems, quite reasonably, that there is a file size limit on what can be added. However i’d made another commit since adding the file.

So for the future I document for myself how I got out of the problem.

First you have to get the command prompt git working. Go to Git Settings, on your version of the screen below it will have hyperlink to install 3rd party tools. Follow the link and install them.

image

Right click around the various windows and some of them have the option to open the command prompt, do so.

image

Then…

image

I ran the git rm command but using a directory filter to remove all instances of .pub files from my repository, going right back through all my history. The HEAD command says go to now and I could have specified a commit ID to limit the activity to one commit, but this was not needed. Git rewrote all my commits and so I finally pushed the changes back.

image

Job done!

Git is syncing ok now and I can move on with my prep for Makerfaire uk 2015.