How to clone a bitbucket repository?
Asked Answered
T

8

35

Getting back to work after a while it seems I don't know how to clone a bitbucket repository. Any idea why I get the "not found" error?

git clone --verbose https://bitbucket.org/helllamer/mod_openid
Cloning into 'mod_openid'...
remote: Not Found
fatal: repository 'https://bitbucket.org/helllamer/mod_openid/' not found

System:

git version 1.9.1
uname -a Linux openvpnas2 3.13.0-44-generic #73-Ubuntu SMP Tue Dec 16 00:22:43 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
Trapeziform answered 25/1, 2016 at 15:30 Comment(7)
Go to the bitbucket repository that you want to clone, on the left pane, there is a clone option. Clicking that will give you a link to the repository. Copy that and try git clone url-from-bitbucket. This should work!Depreciable
@SajibAcharya I'm sorry but there is no "clone" option. The only url I could find is "bitbucket.org/helllamer/mod_openid" . Let me know if you find otherwise.Trapeziform
where did you get this url from? It says 404 when I click it. Moreover, bitbucket clone urls do not look like the one you posted. It kind of looks like https://username@bitbucket/path/to/project. You sure you are using the right url?Depreciable
Plus, if it is a git repo, it should have a .git in the end. You URL is malformed.Depreciable
It has no .git extension. I found the repository on the bitbucket website... I don't get why you can't reach it. Here is a printscreen with the URL of the repo i.imgur.com/1H5poUy.pngTrapeziform
...and then there are people who downvotes a question without giving any specific reason -_-Depreciable
the bitbucket documentation is totally unhelpful here. But guesswork (helped by the above answers, and experience with github) enabled me to clone the repository I wanted, which is bitbucket.org/amintimany/categories the command was git clone bitbucket.org/amintimany/categories.git contrary to the answers above, I saw no clone button or clone option, and nothing like the screenshot shown above. And contrary to the bitbucket documentation there is no + symbol to click onBezique
E
25

This is a Mercurial repository, not a Git repository. Bitbucket supports both systems.

Clone with:

hg clone https://bitbucket.org/helllamer/mod_openid

For more information about Mercurial please see its Wikipedia page.

Effluent answered 25/1, 2016 at 15:55 Comment(7)
Thanks @Chris! I've just found that few seconds ago... It's worth to mention that the UI is not that helpful .Trapeziform
Agreed! It took me a few minutes to figure this out as well.Effluent
On bigger screens it gives a full blown descriptive side panel, unlike on browsers in small screens.Depreciable
@SajibAcharya, I assure you that I'm using a very big screen. The side panel doesn't seem to include any information about which version control system this repository uses. The only place I see it is as part of the SSH clone URLs.Effluent
I am using a 15.6' screen with Firefox on Ubuntu. I get the bitbucket website like this. i.imgur.com/YNFqwxF.pngDepreciable
@SajibAcharya, where in that screenshot do you see an indication that we're dealing with a Mercurial repository?Effluent
@Chris, I was indicating about the cloning option that the website provides, not the type of repository. But if you click on clone, it does show the hg clone ... command from which we could get an idea.Depreciable
W
33

On the left side of bitbucket screen there is a vertical column with buttons. The second button from the top is "CLONE" button . Press on this button .You will get HTTP address . enter image description here

Copy this address and use in git in regular way :

git clone <HTTP address of repo>

Weidner answered 18/5, 2018 at 7:56 Comment(1)
The bitbucket idea is: hiding it somewhere that people can't find it easilyOversight
E
25

This is a Mercurial repository, not a Git repository. Bitbucket supports both systems.

Clone with:

hg clone https://bitbucket.org/helllamer/mod_openid

For more information about Mercurial please see its Wikipedia page.

Effluent answered 25/1, 2016 at 15:55 Comment(7)
Thanks @Chris! I've just found that few seconds ago... It's worth to mention that the UI is not that helpful .Trapeziform
Agreed! It took me a few minutes to figure this out as well.Effluent
On bigger screens it gives a full blown descriptive side panel, unlike on browsers in small screens.Depreciable
@SajibAcharya, I assure you that I'm using a very big screen. The side panel doesn't seem to include any information about which version control system this repository uses. The only place I see it is as part of the SSH clone URLs.Effluent
I am using a 15.6' screen with Firefox on Ubuntu. I get the bitbucket website like this. i.imgur.com/YNFqwxF.pngDepreciable
@SajibAcharya, where in that screenshot do you see an indication that we're dealing with a Mercurial repository?Effluent
@Chris, I was indicating about the cloning option that the website provides, not the type of repository. But if you click on clone, it does show the hg clone ... command from which we could get an idea.Depreciable
A
4

To clone a repository with HTTPS, first you should generate an access token (you can't use your login password anymore) and then clone the repository with this generated token.

Generate access token:

Personal settings > App passwords > create app password

Clone the repository:

git clone https://[email protected]/YOUR-REPOSITORY

It will prompt you for generated token.

Audriaaudrie answered 25/6, 2022 at 10:25 Comment(0)
J
1

It is simple and same as in GitHub. Go to Bitbucket repository from your browser and copy url. Open a terminal in desired location, where you want to clone the repository, and then type this:

git clone <copied url of repo.>

Then it ask your Bitbucket username and password. After providing them, you can clone it.

Junkman answered 24/10, 2017 at 7:15 Comment(0)
D
0

Most probably it is a private repository where you have access permissions and I do not. What you need to do is move your mouse on the three dots on the left pane at the top (refer the image) and then you'd get a pop up where you'd find the clone option. Click on that and you'd get a command like hg clone bitbucket-url (It is a Mercurial repository as mentioned by Chris). Copy that and paste it on your terminal. You'll be able to clone that if you have permissions to access the repository.

Depreciable answered 25/1, 2016 at 15:54 Comment(0)
V
0

The following works for me for Mercurial repository.

hg clone https://[YourUserName]@bitbucket.org/tr_radlab/radlab-for-windows/branch/default

Put your user name in place of [YourUserName] in above Url.

Voncile answered 3/8, 2017 at 16:18 Comment(0)
N
0

At best you need to simply download so you could either use sourcetree or use Mercurial to enjoy cloning if you are not the cmd type.

Niehaus answered 25/2, 2019 at 7:8 Comment(0)
M
0
#!/bin/bash

# Set your Bitbucket username and password
BITBUCKET_USERNAME='<<your username>>'
BITBUCKET_APP_PASSWORD='<<your password>>'

# Set the user or team name whose repositories you want to clone
TEAM_NAME='<<team name>>'
LIMIT=50

# Generate a timestamp in the format YYYY-MM-DD
timestamp=$(date +%Y%m%d%H%M%S)

# Get the current date in the format YYYY-MM-DD
DATE=$(date +%F)

# Create a backup directory with the current date and proper permissions
BACKUP_DIR="backup_$DATE"
mkdir $BACKUP_DIR
chmod 700 $BACKUP_DIR

while true; do
  # Use the Bitbucket API to get a list of repositories for the specified team, for the current page
  REPOS=$(curl -u "$BITBUCKET_USERNAME:$BITBUCKET_APP_PASSWORD" -X GET "https://api.bitbucket.org/2.0/repositories/$TEAM_NAME?pagelen=$LIMIT&page=$PAGE_NUM")

  # Exit the loop if no repositories are returned
  if [[ "$REPOS" == *"\"values\":[]"* ]]; then
    break
  fi

  # Parse the JSON to extract the repository slugs
  REPOS=$(echo "$REPOS" | jq -r '.values[].slug')

  # Clone each repository
  for REPO in $REPOS; do
    git clone "https://$BITBUCKET_USERNAME:[email protected]/$TEAM_NAME/$REPO.git"  $BACKUP_DIR/$REPO
  done

  # Increment the page number
  PAGE_NUM=$((PAGE_NUM+1))
done
Militarism answered 11/1, 2023 at 11:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.