Search code examples
gitcommand-line-interfacebitbucketgit-remote

BitBucket - How to retrieve all repository urls from a server


Is there a way to retrieve ALL remote urls from a given BitBucket server.

We have a lot of applications that are being moved from existing SCM to BitBucket. Our BB admins are creating the Repositories for us on the BitBucket server.

We then will get the ssh url similar to (ssh://[email protected]:7999/sample/template-repo.git) for each repository by going to the web interface. We then select the repository we want to use for that run, select clone -> ssh protocol for that repository and copy the info. This url will then be used in the process to populate the repository with files from the current SCM application.

I looked at ls-remote, but I think that is for a different purpose.

I am wondering if there is any commandline git command that will give me the list of ALL the repository urls from the given server in one shot that I can save in a text file and use them in my transition process. I am very new to git and have started working in it only a couple weeks ago. I have not yet found a command to do so.

Appreciate any help with how to do it or any resources that can guide me to achieve my purpose.


Solution

  • That would not be a git command, which has no notion of "server" (it deals only with a single git repo)

    You could try and use the Bitbucket Server REST APIs and see if you can get the list of repos that way (providing your authentication gives you access to all repos).
    Its supported API endpoints includes projects and projects/repos.

     curl -u fred:fred http://<yourBitBucketServer>/rest/api/1.0/projects