I USED to refer to the patch of wasteland at the corner of Leith Links park as "the toilet".

We rarely ventured in there. People generally didn't, except to send their dogs in for a casual poop without scoop, drop their own pants and use it as an outdoor public convenience, or do whatever people do in deserted corners where no-one else goes. When I moved to Leith seven years ago, the two-acre corner was already like that, mysteriously abandoned, untended, as if it were somehow necessary to have part of the park surrendered to alcoholics, drug users, and dogs with lazy owners. Once, people said, it had been a tennis court - though all that was left of that was a rough, battered ground surface. Whatever its history, it felt off-limits; even a little scary.

But all that has changed. Potatoes grow where giant, tree-like thistles used to cluster. Where once the only signs of human impact were crushed lager cans, broken bottles, plastic bags clinging to bushes and the occasional condom or syringe, now there is spinach, beetroot, mizuna, rocket, strawberries, coriander, lettuce, courgette, radishes. Locals are often found digging. Kids squat on piles of earth making dirt kitchens. Last month a gate suddenly appeared in the corner, its metalwork coiled into the name "Leith Community Croft".

Leith Community Croft is not the first or only community garden. The movement started in New York in the 1970s, and has had a resurgence since the global financial crisis - the Obamas even started a Victory Garden at the White House. So ours is just a new seedling on the block, freshly planted, with, at two acres, a little more room than average for growth. Similar green shoots are pushing up across Scotland.

There are gardens in gap sites, such as Woodlands Community Garden, in Glasgow, which operates like an outdoor community centre. There is a "mobile" garden in Edinburgh's Fountainbridge, designed to be shiftable between brownfield sites as they become available or unavailable.

Evie Murray, the key driving force behind Leith Community Croft, believes this is part of a wider "thing that is happening with food".

A former drug addiction counsellor who was made redundant after the economic crash, Murray became interested in the Occupy movement and began connecting with others who were concerned about the economy and "how unequal things were". She started attending talks, about the Fife Diet, food miles and sustainability, and reading articles from Resurgence magazine. She was troubled by the plight of bees.

But also, around this time, she was caring for a lot of children. Currently a single mum of four, she then found herself looking after two more kids from her extended family. "I was wanting," she recalls, "to get out and do stuff outdoors with the children, because it's quite a lot to manage in the house. So I'd started growing plants in a concrete yard outside my home. It was all about spending time with the children."

She started a Facebook page called Community Crops In Pots, about growing food locally in small, unused spaces, and found lots of people connected with it. "Across the whole of Scotland people were getting into the idea of growing food. They'd be posting up pictures, sharing skills." Soon she started collaborating with Dr Bell's Family Centre next door, who shared her yard space, and later began growing crops at her local Stanwell nursery. "Somehow," she recalls, "I became a gardener in the process."

Because of these roots, the project is now very child-friendly. The croft is something I do with my family - my sons, Louis and Max, run in a pack with other children, as we adults do the grafting. From time to time the kids like to help - particularly if it involves spades or sharp implements. And one of the real joys, has been to find one or other of them nibbling away on a freshly plucked leaf. I thought I was the only person in my house who likes beetroot. Then Louis wandered up one day gnawing on a leaf, saying: "Nice leaf. Tastes of beetroot."

Murray and her team are working with local schools and nurseries to promote sustainability and help reduce food miles. "We've gone from a situation in Leith Primary where children aren't really sure where their food is coming from. They think it comes from the supermarket. And we're changing that."

I'm not myself a gardener. Before this year, despite having grown up on a farm, I'd never planted potatoes. Though I've had my name down on the allotment waiting list for nearly seven years, I was starting to wonder if it would ever happen and if I could cope if it did. At home, we have a roof terrace with a few plants. A friend told me if I didn't do better at keeping them alive she would ring up the allotments' administrator and get me taken off the list.

Like many of those involved in this small city croft, I drop in and out. This is our family's favourite Sunday afternoon activity. Occasionally, since I don't know much about sowing seed, I dig out a few thistles. Even us non-gardeners can spot a troublesome large weed and the croft's secretary, Angus Armstrong, is a kindred spirit, who says he's "quite happy battling with those thistles" while someone else does the "important" work like planting vegetables.

Armstrong, whose only prior horticultural experience was planting cress seed at school, somehow found himself agreeing to look at an application for funding from the Climate Change Challenge Fund - and was shocked, while researching it, to find that 30% of Scotland's carbon emissions came from food. He went to a board meeting for Crops In Pots, became the secretary, and soon was going to the council as part of the team pitching to put the croft on this patch of common land. When they left that meeting with permission to go ahead, he was "high as a kite".

Before this, he was "pretty cynical about the idea that there was anything much you could do to make the world any better, because the problems are so huge". But the enthusiasm of Murray and others put him "to shame". "I started to see that this was a way of getting involved in something practical, direct and local. It's just a small thing. That you can do. It's empowering. And at the very least we're going to grow some veg and have a good time with the community coming together."

People get involved for all manner of reasons: for the social company; because they like the outdoors; because they don't have their own gardens. But a significant number see this as a distinctly political act, which in its own small way is world-changing. As Armstrong puts it: "It's like a pebble that's dropped in a pool and the ripples move out. And then you get lots of pebbles and lots of little ripples."

Across Scotland there are already many such pebbles. One has been dropped a stone's throw away in Granton, one of Edinburgh's more deprived areas. There, Tom Kirby, one of the founders of Granton Community Gardens, ambles between tall, tendrilled pea plants and a bank of recently ripened strawberries. These gardens have been going for five years, and are lush little plots of paradise occupying once empty street corner spaces. Kirby sees them as, among other things, a social hub. Community gardening, he says, "is about 25% looking after plants, and 75% chat". For Kirby it is also "a very sane" thing to do. "It's what people have done through history all around the world - look after a wee bit of land, grow stuff on it. It's good for mental health, but also politically, and for the area."

As we stand grazing on sugar snaps, Mary Mbae, who moved to Scotland from Kenya 13 years ago, drops in to eye up the strawberries. She has been gardening since childhood and recalls that her father had four wives, each of whom was given two acres to farm for their children. She is one of the garden's most enthusiastic workers, an advocate of kale, a vital part of the Kenyan diet. "How we decide what to plant is very easy," she says. "Scottish food and African food."

Granton's community gardeners grow more than enough for the volunteers to eat, so they share it with their neighbours and make huge community meals (their biggest for 250 people). They have also started a Garden Cafe, offering food for free or a small donation, which is their "attempt to come up with a better alternative to food banks". On the menu this week, there is chicken curry with those sugar snap peas.

A community garden is different from an allotment. The latter, small, enclosed fruit and veg kingdoms, are more private, more exclusive, more daunting for the outsider - barricaded as they are behind long waiting lists. Community gardens are a shared experience. "They mean that you're connecting outwardly," says Murray. "You're somehow taking the allotment experience out to the community and bringing people in to experience it."

On the first damp Sunday in February when we all gathered at the croft, it seemed like a strange, apocalyptic wasteland. Mud-splattered kids rampaged around brandishing metal poles and litter pickers. People collected mountains of old crisp packets, cans and wrappers, bringing them into the centre for sorting and recycling. A whole box of barely-drunk water bottles was collected and kept for irrigation. It was filthy, often smelly work, but strangely satisfying. And in the process, I was reminded of how much I enjoyed just doing a simple, if mucky, physical job with a big group of other people. It's a small, and very basic thing - but it is a thrill.

Today, there is still rubbish to pick up. People continue to send in their dogs to fertilise the soil, and even the occasional human passer-by still regards it as a public toilet. But this corner of Leith is no longer just that. It's a space in which I watch my kids attempt to pull out thistles, pluck leaves to chew on, and make "houses" behind bushes. Last Sunday I took home some spinach. It was very special spinach: produced not by some shop, but by a crowd of people I have come to know, most of whom have weeded and planted a lot harder than me. It felt like the greenest leaf I'd ever eaten.