The 27-year-old former Brighton midfielder is back in Sussex on a contract until the end of the season and could make his debut against Rotherham on Saturday.
Town manager John Gregory told the club website: " We have been monitoring Gary for some time and I watched him again on Tuesday when he was excellent for Rochdale against Chesterfield in their top-of-the-table clash.
"He's a really good ball-playing midfielder. He gets stuck in but he's also very good on the ball and he is really keen to make this move work for him.
"We have taken him initially until the end of the season but if all goes well I can definitely see him being here beyond that.
"That's up to Gary, of course, but he has all the attributes to be a success at this football club for a long time to come."