LoginSignup
2
2

More than 5 years have passed since last update.

何回やってもBitbucketにPush出来ない

Last updated at Posted at 2018-08-03

Rails Tutorial 1.4.3 Bitbucket

SSH鍵を作成してpushするとエラー

It is required that your private key files are NOT accessible by others. This private key will be ignored.

チュートリアルを参照に手順通り進めると先ず突き当たる一つ目の壁。

 chmod 0600 ~/.ssh/id_rsa

terminalにて以上のコマンドを打つことで、鍵のpermissionを変更が可能とのこと。

鍵のpermissionを変更してpushしてもエラー

repository access denied. access via a deployment key is read-only. fatal: Could not read from remote repository.

レポジトリを作成して、レポジトリ設定からSSH鍵を登録すると起こるエラーがこれ。
レポジトリではなく、bitbucket=>ユーザーアイコンからbitbucket設定を選択してこちらに登録。

それでもまだエラーが発生

hint: Updates were rejected because the remote contains work that you do
hint: not have locally. This is usually caused by another repository pushing
hint: to the same ref. You may want to first integrate the remote changes
hint: (e.g., 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

なぜかこのようなエラーが発生したので

git pull origin master

マージさせることで解決?

git pull origin masterを行ってもエラー

 git fetch && git merge origin/master

こうすればよいという記述を参考にトライ、無事以下のエラーが発生

fatal: refusing to merge unrelated histories

それでもまだエラーが発生

Automatic merge failed; fix conflicts and then commit the result.
 git merge --allow-unrelated-histories origin/master

先ほどのコードにハイフン以下の記述を加えてみる。

git push -u origin masterがエラー

conq: repository does not exist.
fatal: Could not read from remote repository.
Please make sure you have the correct access rights and the repository exists

このエラーに遭遇したら以下のように打ち直すことで解消。

git remote set-url origin git@bitbucket.org:ユーザー名/リポジトリ名.git

bitbucketのソースを開くと表示されない

どうやらここにはないようですそのファイルまたはディレクトリは存在しません。前のページに戻り別のもので試してください。

コミットの履歴や変更日時は表示されるのに、該当ファイル(ソース)を開くとエラーが発生。
こればかりはお手上げ。
原因はおそらく、レポジトリを作成する際に「Readmeファイルを作りますか?」という項目にチェックを行ったことでrailsファイルにあるReadmeファイルとの競合が発生した為に起こったエラーと考えられる。
結局レポジトリを削除し、アカウントを削除した後に、再度作り直してReadmefile作成のチェック項目を外して、再び

git push -u origin master

を行うと再び同じエラー群に遭遇するので順不同に上記の解決コードを入力したのちに、

git remote set-url origin git@bitbucket.org:ユーザー名/リポジトリ名.git

上記コードを実行することでソースが無事表示されるように。

参考サイト
https://qiita.com/mizukmb/items/f12765a9efdaeb2973e5
https://qiita.com/takanatsu/items/fc89de9bd11148da1438
https://hacknote.jp/archives/15275/
https://qiita.com/tt0805/items/fdcffa0ee0fe0f0f6038
https://qiita.com/bird_tummy/items/216d760c9c05e8470014
https://confluence.atlassian.com/bitbucket/add-unversioned-code-to-a-repository-877177133.html

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