Clone all repositories from a project in stash

Is there a way i can clone all the existing repositories from a project in stash in a simple way?

Lets say I have project called "A" and there are 5 reporitories say 1,2,3,4,5. I would like to clone all the repositories in project A in a simple way rather than doing

git clone

git clone

git clone

git clone

git clone


7 answers

1 accepted

1 vote
Accepted answer

Hi Vishal,

I'm afraid Git doesn't allow that, they have to be cloned separately.

Hypothetically you could have another repository that uses Submodules to link to the others, and then use git submodule to clone them down. You would have to keep that other repository up-to-date, which would be a pain. Submodules link by using commits. I personally wouldn't recommend that - it's not really buying you much.

You could also write a script that uses Stash's REST resources to list the repositories in a project and then clone them all in succession.

I'm curious - how often are people clone the repositories? Once you have them locally you dont' really need to clone them again. Is this for a build perhaps?



Hey charles - Thanks for the prompt response. Yes it is for the build purpose. I will be working all the repositories of all the projects from various teams. I want a simply way to clone all repositories.

Like 1 person likes this

Hi Vishal,

I thought so. :)

So it's gets interesting at this point. What kind of dependencies do you have between each of your repositories then? If you clone them all down, how do you know what version/branch of each repository to build? Is it always master? If that's the case how do you handle old release versions?

Generally I would recommend that you would except one build per repository. So what we do here is use maven as our dependency management, and we use maven versions to tie two separate repositories together. It means we can make changes to one repository without affecting another.

You might find that submodules are an easy(ish) way to get started with this kind of versioning. As mentioned previously, you can have another repository would would then 'link' all of your child repositories together at specific versions. You would then need to modify this parent repository before changes in a child repo was built. This may or may not be what you are looking for. Depending on your language/environment you might be able to use something like Ruby Gems, Python Eggs, etc. I would recommend these over using submodules, but would require a more substantial change to your build process.

The quick answer to your actual question would proably be to just configure your build (Bamboo? Jenkins?) to clone each repository manually. I know in Bamboo you can have multiple repositories per plan. It's not really an automated solution - but it's probably the easiest (assuming you don't have like 100 repositories).

Sorry for the long rant.


Hey Charles -

There is no dependency between the repositories. I want latest version of code of all the repositories to be available. We will build anything which is latest and yes it is always master. I am handling old releases with TAG's.

I have around 20 repositories. And My build system(Jenkins) is configured to build individual repositories. Its just my individual request that I want to clone each and every repository in stash.

I will try submodules and thanks again!!!


Here is quick script using stashy - a python rest api client for stash:

# stashget PROJECT_KEY


import sys
import os
import stashy

stash = stashy.connect("http://localhost/stash", "USERNAME", "PASSWORD")
for repo in stash.projects[sys.argv[1]].repos.list():
    for url in repo["links"]["clone"]:
        if (url["name"] == "ssh"):
            os.system("git clone %s" % url["href"])

Thanks Faik, works awesome!

hi, as of 'm running the above script m getting error. so can you please tell me which all places i have to edit and place my data.

$ curl -s  -k --user YourUserName | python -c 'import sys, json; r = json.loads(; [sys.stdout.write(d["name"]+"\n") for d in r]'



We are facing the same problems with > 50 projects and > 100 repositories. Most of them are built with Jenkins . 

There is one project to configure the build jobs of Jenkins and I am working on the small management component (internally called "Metagit"). This is based on the stash-java-client ( and uses Ant as a frontend.


We automate the following workflows:

1. Pull / Clone a set of repos

2. Create a feature branch

2a. Search and modify (if needed) e.g. Maven versions ...

2b. Commit and Push

3. Create a Pull Request for the new branch



If you're using git bash or cmd in your local (which I think most of us use)
you can just type the following 

for i in reponame1 reponame2 reponame3 ...
git clone"projectcode"/$i.git

Hi guys, I found this discussion while looking for similar solution. The python stashy didn't work for me, so I wrote simple Java app which do the same:

It actually access all projects where user has permission to read, iterate trough all repositories of all projects and clone them to directory structure:


|---- repo1

|---- repo2


|---- repo1

|---- repo2



Using @Ladislav Jech answer ,I have created a repo with springBoot Rest api to clone all repos from url.

Thanks to archenroot


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 06, 2018 in Bitbucket

Upgrade Best Practices

Hello! My name is Mark Askew and I am a Premier Support Engineer for products Bitbucket Server/Data Center, Fisheye & Crucible. Today, I want to bring the discussion that Jennifer, Matt, and ...

1,931 views 7 10
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you