git 如何克隆一个bitbucket仓库?

eufgjt7s  于 2023-01-24  发布在  Git
关注(0)|答案(8)|浏览(507)

一段时间后,当我回到工作中时,我似乎不知道如何克隆一个bitbucket仓库。你知道为什么我会得到"未找到"的错误吗?

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

系统:

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
jmp7cifd

jmp7cifd1#

在bitbucket屏幕的左侧有一个带按钮的垂直列。从顶部数第二个按钮是“克隆”按钮。按下此按钮。您将获得HTTP地址。

复制此地址并在git中以常规方式使用:
git clone <HTTP address of repo>

mspsb9vt

mspsb9vt2#

这是一个 Mercurial 存储库,不是Git存储库。Bitbucket supports both systems
克隆:

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

有关Mercurial的详细信息,请参阅its Wikipedia page

lbsnaicq

lbsnaicq3#

它很简单,和GitHub中的一样。从你的浏览器进入Bitbucket仓库并复制url。在你想要克隆仓库的位置打开一个终端,然后输入:

git clone <copied url of repo.>

然后它会询问你的Bitbucket用户名和密码。提供后,你就可以克隆它了。

hrysbysz

hrysbysz4#

很可能是一个私有存储库,您有访问权限,而我没有。您需要做的是将鼠标移动到左侧窗格顶部的三个点上(请参阅图片),然后您会看到一个弹出窗口,在其中可以找到克隆选项。单击该选项,您会看到类似hg clone bitbucket-url的命令(正如Chris提到的,这是一个Mercurial存储库)。复制并粘贴到您的终端上。如果您有权限访问存储库,您将能够克隆它。

xxhby3vn

xxhby3vn5#

下面的代码适用于Mercurial存储库。

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

将您的用户名替换为上述URL中的[YourUserName]。

pxiryf3j

pxiryf3j6#

最好的情况下,您只需要简单地下载,这样您就可以使用sourcetree或使用Mercurial来享受克隆,如果您不是cmd类型的话。

plupiseo

plupiseo7#

要使用HTTPS克隆存储库,首先您应该生成一个访问令牌(您不能再使用登录密码),然后使用此生成的令牌克隆存储库。

生成访问令牌:

个人设置〉应用密码〉创建应用密码

克隆存储库:
git clone https://YOUR-USERNAME@bitbucket.org/YOUR-REPOSITORY

它将提示您输入生成的令牌。

tvmytwxo

tvmytwxo8#

#!/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:$BITBUCKET_APP_PASSWORD@bitbucket.org/$TEAM_NAME/$REPO.git"  $BACKUP_DIR/$REPO
  done

  # Increment the page number
  PAGE_NUM=$((PAGE_NUM+1))
done

相关问题