Can i record continuously, keeping just the last N minutes?
Short answer: no.
Long answer, maybe. You have very limited scripting ability via the auto update function of the camera. You simply drop a text file called "autoexec.sh" on the SD card before turning the camera on and the camera will execute the script. Though I haven't seen a script that would do something like infinite recording by erasing the oldest part of the recording.

Maybe you are able to delete certain files from the SD card via the scripting interface, in that case you wouldn't be able to do seamless infinite recordings but you could record in N minute intervals and delete the oldest file after x recordings when you know that you probably have nearly used up the sdcard space.

You might also be able to do this by doing said interval recordings and have the GoPro's wifi webserver monitored by a computer that deletes the oldest file on the camera once you reach critical storage space.
In case deleting via the camera script interface isn't doable.

All needed info about this hack can be found here (horrible site but lots of information) and some existing scripts here.