The 26-year-old winger left Cheltenham at the end of the season after rejecting a new deal and said the prospect of joining Gills ticked all the right boxes after serving his time in Sky Bet League Two.
McGlashan told the club's official website: "Gillingham has a good fan base and with the gaffer being an ex-winger I feel I can improve. He wants athletic players this year and I feel I fit in to that criteria.
"I turned down the club in the past but it didn't happen then, I'm here now and hopefully I can hit the ground running.
"It's my first opportunity in League One so it's important I get my sharpness and get a good pre-season under my belt."
McGlasham has nearly 200 professional appearances under his belt since joining Aldershot in 2010, after coming through at Staines and plying his trade with various non-league clubs.
He left Aldershot for Cheltenham, where he spent two-and-a-half successful years, before leaving in the summer. He made 46 appearances for the Robins last season, scoring six goals.