LoginSignup
14
14

More than 5 years have passed since last update.

Bitbucket REST APIでターミナルから新規リポジトリ作成

Posted at

公式リファレンスこちらの記事を参考に。

.bashrcや.zshrcに以下を記述します。

.zshrc
# 新規リポジトリを作成するコマンド
# createRepoは好きな関数名で
function createRepo() { \
    curl -v -X POST -u [ユーザ名]:[パスワード] \
    -H "Content-type: application/json" \
    https://api.bitbucket.org/2.0/repositories/[ユーザ名]/$1 \
    -d '{"scm":"git", "is_private":true, "fork_policy":"no_forks" }' \
};

-vオプションは好みで。
また、jsonで渡しているパラメータについてはそれぞれ以下の通り。

パラメータ 意味
scm "git"または"hg"
is_private trueならプライベートリポジトリ
fork_policy allow_forks : フォークを許可
no_public_forks : プライベートフォークのみ許可
no_forks : フォーク不可

source .zshrcした後

createRepo [作成したいリポジトリ名]

でリポジトリ作成。

これで、Bitbucketをブラウザで開くことなく開発を始めることができます。

14
14
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
14
14