讨厌在流程上问这个问题,但对于我的生活,我无法弄清楚或找到有关如何以新的Bit Bucket格式访问旧提交源的文档 . 这甚至可能了吗?太沮丧了!
几年前的好答案 . 现在Bitbucket让它变得更容易了 .
标记您要下载的提交(如Rudy Matela的回答中所述) .
然后转到下载并单击“标签”选项卡,您将获得多个下载选项 .
我知道您想通过BitBucket Web界面下载旧版本而不使用Mercurial / Git客户端 .
检查这个related question . 在评论中,有人说没有办法做到这一点 . 幸运的是,这并不完全正确 .
通过在BitBucket项目页面上导航,我找不到下载任意版本的链接 . 有以下格式下载特定标签的链接:
https://bitbucket.org/owner/repository/get/v0.1.2.tar.gz
但是通过调整上面的url,通过提交哈希更改标记名称,如:
https://bitbucket.org/owner/repository/get/A0B1C2D.tar.gz
您实际上可以下载特定版本 .
正如Rakka Rage在评论中所提到的,将 .tar.gz 替换为 .zip 也有效 .
.tar.gz
.zip
我知道这已经太晚了,但是你可以使用API 2.0
从命令行:
curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>
或者在php中:
$data = json_decode(file_get_contents("https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>", true));
然后你有你的文件的历史(从最近的提交到最旧的提交):
{ "pagelen": 50, "values": [ { "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<hash>/<path_file>" }, "meta": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD>/<path_file>?format=meta" }, "history": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD>/<path_file>" } }, "commit": { "hash": "<HEAD>", "type": "commit", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD>" }, "html": { "href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD>" } } }, "attributes": [], "path": "<path_file>", "type": "commit_file", "size": 31 }, { "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>" }, "meta": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/src/<HEAD~1>/<path_file>?format=meta" }, "history": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<HEAD~1>/<path_file>" } }, "commit": { "hash": "<HEAD~1>", "type": "commit", "links": { "self": { "href": "https://api.bitbucket.org/2.0/repositories/<user>/<repo>/commit/<HEAD~1>" }, "html": { "href": "https://bitbucket.org/<user>/<repo>/commits/<HEAD~1>" } } }, "attributes": [], "path": "<path_file>", "type": "commit_file", "size": 20 } ], "page": 1 }
其中 values > links > self 提供历史记录中的文件,您可以使用 curl <link> 或 file_get_contents(<link>) 检索该文件 .
values
links
self
curl <link>
file_get_contents(<link>)
最后,您可以从命令行过滤:
curl https://api.bitbucket.org/2.0/repositories/<user>/<repo>/filehistory/<branch>/<path_file>?fields=values.links.self
在PHP中,只需在数组 $data 上进行 foreach 循环 .
$data
foreach
注意:如果 <path_file> 有 / ,则必须在 %2F 中进行转换 .
<path_file>
/
%2F
请参阅此处的文档:https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/filehistory/%7Bnode%7D/%7Bpath%7D
Step 1
Step 2
Step 3
Step 4
Final Step
为了记录,您还可以通过这种方式玩弄URL:
浏览最新的源代码时,您会看到以下内容: https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master
https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master
只需更改提交哈希并删除GET参数: https://bitbucket.org/my/repo/src/wantedcommithash/my.file
https://bitbucket.org/my/repo/src/wantedcommithash/my.file
上面有一个@HeinA.Grønnestad:它一切正常,真的很想知道为什么GUI中没有任何东西可以使用它 .
您可以通过在URL中附加 ?until=<sha-of-commit> (在文件名之后)来查看文件的源,直到特定的提交 .
?until=<sha-of-commit>
万一有人在我的船上,这些答案都没有完全奏效,这就是我所做的 .
也许我们内部的Bitbucket服务器设置与大多数不同,但这里是我通常只是为了查看主分支中的文件的URL:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse
如果我从下拉菜单中选择一个不同于master的分支,我会得到:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=refs%2Fheads%2F<BRANCH_NAME>
所以我尝试这样做,它工作:
https://<BITBUCKET_URL>/projects/<PROJECT_GROUP>/repos/<REPO_NAME>/browse?at=<COMMIT_ID>
现在我可以浏览整个回购,因为它是在提交时 .
我试图弄清楚是否可以在GitHub上浏览早期提交的代码并将它带到这里 . 我使用了我在这里找到的信息,在摆弄了网址之后,我实际上找到了一种浏览旧提交代码的方法 .
当您浏览代码时,URL类似于:
https://bitbucket.org/user/repo/src/
并在最后添加一个提交哈希,如下所示:
https://bitbucket.org/user/repo/src/a0328cb
您可以在该提交时浏览代码 . 我不明白为什么没有直接选择提交的下拉框,该功能已经存在 . 奇怪 .
8 回答
几年前的好答案 . 现在Bitbucket让它变得更容易了 .
标记您要下载的提交(如Rudy Matela的回答中所述) .
然后转到下载并单击“标签”选项卡,您将获得多个下载选项 .
我知道您想通过BitBucket Web界面下载旧版本而不使用Mercurial / Git客户端 .
检查这个related question . 在评论中,有人说没有办法做到这一点 . 幸运的是,这并不完全正确 .
通过在BitBucket项目页面上导航,我找不到下载任意版本的链接 . 有以下格式下载特定标签的链接:
但是通过调整上面的url,通过提交哈希更改标记名称,如:
您实际上可以下载特定版本 .
正如Rakka Rage在评论中所提到的,将
.tar.gz
替换为.zip
也有效 .我知道这已经太晚了,但是你可以使用API 2.0
从命令行:
或者在php中:
然后你有你的文件的历史(从最近的提交到最旧的提交):
其中
values
>links
>self
提供历史记录中的文件,您可以使用curl <link>
或file_get_contents(<link>)
检索该文件 .最后,您可以从命令行过滤:
在PHP中,只需在数组
$data
上进行foreach
循环 .注意:如果
<path_file>
有/
,则必须在%2F
中进行转换 .请参阅此处的文档:https://developer.atlassian.com/bitbucket/api/2/reference/resource/repositories/%7Busername%7D/%7Brepo_slug%7D/filehistory/%7Bnode%7D/%7Bpath%7D
Step 1
Step 2
Step 3
Step 4
Final Step
为了记录,您还可以通过这种方式玩弄URL:
浏览最新的源代码时,您会看到以下内容:
https://bitbucket.org/my/repo/src/latestcommithash/my.file?at=master
只需更改提交哈希并删除GET参数:
https://bitbucket.org/my/repo/src/wantedcommithash/my.file
上面有一个@HeinA.Grønnestad:它一切正常,真的很想知道为什么GUI中没有任何东西可以使用它 .
您可以通过在URL中附加
?until=<sha-of-commit>
(在文件名之后)来查看文件的源,直到特定的提交 .万一有人在我的船上,这些答案都没有完全奏效,这就是我所做的 .
也许我们内部的Bitbucket服务器设置与大多数不同,但这里是我通常只是为了查看主分支中的文件的URL:
如果我从下拉菜单中选择一个不同于master的分支,我会得到:
所以我尝试这样做,它工作:
现在我可以浏览整个回购,因为它是在提交时 .
我试图弄清楚是否可以在GitHub上浏览早期提交的代码并将它带到这里 . 我使用了我在这里找到的信息,在摆弄了网址之后,我实际上找到了一种浏览旧提交代码的方法 .
当您浏览代码时,URL类似于:
并在最后添加一个提交哈希,如下所示:
您可以在该提交时浏览代码 . 我不明白为什么没有直接选择提交的下拉框,该功能已经存在 . 奇怪 .