git - CURL 从具有安全性的 BitBucket 存储库中获取原始文件

标签 git curl bitbucket

我正在尝试使用 curl 和以下命令从 Bitbucket 存储库获取原始文件(我尝试了很多,但我包括最后两个):

curl  -L -O  https://user:password@bitbucket.org/username/repository/branch/HEAD/filename.txt
curl  -L -O  https://user:password@bitbucket.org/username/repository/branch/raw/filename.txt

我有一个提交到 master 分支的文件,名为 filename.txt

我想获取上述文件的原始版本。我需要什么代码才能得到它?我从这些命令中得到的只是页面包含的 HTML 代码。

注意:对于这种特定用途,安全性不是问题。我还在以下链接中尝试了解决方案:Download private BitBucket repository zip file using http authentication

最佳答案

您几乎成功了,请尝试以下操作:

curl -O -u username:password https://bitbucket.org/username/repository/raw/branch/filename.txt

Here is the documentation for curl

  • -O, --remote-name: "Write output to a local file named like the remote file we get. (Only the file part of the remote file is used, the path is cut off.)"

  • -u, --user <user:password>: "Specify the user name and password to use for server authentication."

关于git - CURL 从具有安全性的 BitBucket 存储库中获取原始文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54200009/

相关文章:

git - 基于主 Git 项目创建子项目。

git - sbt-release 无法 git push

PHP/ curl : HEAD Request takes a long time on some sites

bitbucket - 有没有办法找出我团队中用户的电子邮件地址

git - 在本地 rebase 后更新 git pull 请求

grails - 获取 paypal rest api grails 的访问 token

laravel - Guzzle 发布嵌套数组问题

git - GitHub/BitBucket 可以做成你的本地仓库吗?

version-control - 将旧项目历史转移到 DVCS

git - 如何自定义 git rebase --interactive 提交消息的格式?