0
0

More than 1 year has passed since last update.

【AWS】エラー:The action failed because no branch named main was found in the selected AWS CodeCommit repository XXX. Make sure you are using the correct branch name, and then try again. Error: null

Posted at

こんにちは。

今回AWS CodeCommitを初めて使い始めました。いつもGithubを使っているため、最初CodeCommitの設定周りで少し迷ったところがあったのでシェアします。もし同じエラーで困っている方の役に立てれば幸いです。

エラー内容

The action failed because no branch named main was found in the selected AWS CodeCommit repository XXX(レポジトリ名). Make sure you are using the correct branch name, and then try again. Error: null

→ 多くの方がGitでデフォルトブランチ(ルートブランチ)として使っているのは「main」もしくは「master」かと思います。私は後者です。笑
今回私がこのエラーになった理由は、mainブランチがAWS CodeCommitのデフォルトブランチに指定されているリポジトリをクローンしてきて、mainブランチは使わないから削除してmasterブランチで作業したのが原因でした。
別にmainにするかmasterにするかについて制限はないので、このような場合はAWS CodeCommit側でデフォルトブランチを変更する必要があります。

解決

① AWS CLI

aws codecommit update-default-branch --repository-name リポジトリ名 --default-branch-name ブランチ名

② コンソール操作

一番わかりやすいコンソール操作です。以下は設定画面です。
image.png
image.png
デフォルトブランチを変更したいリポジトリ設定を開き、スクロールすると上記のようにデフォルトブランチ設定画面が表示されますのでこちらで変更します。

image.png
変更を保存すると上記のようにデフォルトブランチが変更されますので解決です!

より詳しい情報は、以下のAWSドキュメントをご参照ください。⇣
https://docs.aws.amazon.com/codecommit/latest/userguide/how-to-change-branch.html

投稿をご覧いただきありがとうございます。

0
0
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
0
0