質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

BitBucket

BitBucketは無料のリポジトリ管理ホスティングサービスです。 MercurialとGitのVCSに対応しています。プライベートリポジトリを、制限なく作成することが可能です。

Q&A

解決済

2回答

13095閲覧

Bitbucketにpushするとエラーになる

kouta1612

総合スコア7

Git

Gitはオープンソースの分散バージョン管理システム(DVCS)です。

MacOS(OSX)

MacOSとは、Appleの開発していたGUI(グラフィカルユーザーインターフェース)を採用したオペレーションシステム(OS)です。Macintoshと共に、市場に出てGUIの普及に大きく貢献しました。

BitBucket

BitBucketは無料のリポジトリ管理ホスティングサービスです。 MercurialとGitのVCSに対応しています。プライベートリポジトリを、制限なく作成することが可能です。

0グッド

4クリップ

投稿2018/03/24 06:13

編集2018/03/24 06:32

前提・実現したいこと

railsチュートリアル2章を進めている最中に行き詰まってしまいました。
生成したファイルを新しいリモートリポジトリにプッシュする時にエラーが発生します。
pushするにはどうすればよいでしょうか?
どなたかご教授下さい。

発生している問題・エラーメッセージ

$ git push -u origin --all を実行すると、以下のエラーが発生します。 error: failed to push some refs to 'git@bitbucket.org:kouta1612/toy_app.git'

色がついているコードを実行するとエラーが起こる

色がついているコードを実行するとエラーが起こる

エラーメッセージ

エラーメッセージ

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

退会済みユーザー

退会済みユーザー

2018/03/25 02:40

リモートリポジトリの中身はREADME.md だけですか?
kouta1612

2018/03/25 21:59

はい、それだけです。
guest

回答2

0

ベストアンサー

リモート上にあるファイルがREADME だけということなので
誤って作成(よく読まずにチェックして作成)したのならば

git push -f origin master

で強制プッシュしてしまってもいいかもしれません。

コマンドがよく理解できないのであればTortoiseGIT等のGUIツールを利用してはいかがでしょうか

投稿2018/03/25 22:43

退会済みユーザー

退会済みユーザー

総合スコア0

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kouta1612

2018/03/26 11:04

無事リモートにプッシュすることが出来ました!!! 本当にありがとうございます。また機会があればよろしくおねがいします。
guest

0

error: failed to push some refs to 'git@bitbucket.org:xxxxxx.git'

の次の行に

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.

と書かれています。

ヒント:ローカルにない作業がリモートに含まれているため、更新が拒否されました。(..略..)
もう一度 push する前に、リモートの変更を統合することができます。(例えば、 'git pull ...')

ということなので、リモートリポジトリが空ではなくて、ローカルにない作業情報が含まれているので、失敗しています、

まず、

git pull origin master

を実行して、リモートの作業内容をローカリリポジトリに取り込んでから

git push -u origin master

を実行したら 成功しないでしょうか?

投稿2018/03/24 15:06

編集2018/03/25 02:13
CHERRY

総合スコア25171

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

kouta1612

2018/03/25 01:39

回答有り難うございます。 git pull origin master を実行したところ、以下のレスが帰ってきました。 From bitbucket.org:kouta1612/hello_app * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories その後、git pull -u origin master を実行したところ、以下のレスが帰ってきました。 error: unknown switch `u' usage: git pull [<options>] [<repository> [<refspec>...]] -v, --verbose be more verbose -q, --quiet be more quiet --progress force progress reporting Options related to merging -r, --rebase[=<false|true|preserve|interactive>] incorporate changes by rebasing rather than merging -n do not show a diffstat at the end of the merge --stat show a diffstat at the end of the merge --log[=<n>] add (at most <n>) entries from shortlog to merge commit message --squash create a single commit instead of doing a merge --commit perform a commit if the merge succeeds (default) --edit edit message before committing --ff allow fast-forward --ff-only abort if fast-forward is not possible --verify-signatures verify that the named commit has a valid GPG signature --autostash automatically stash/stash pop before and after rebase -s, --strategy <strategy> merge strategy to use -X, --strategy-option <option=value> option for selected merge strategy -S, --gpg-sign[=<key-id>] GPG sign commit --allow-unrelated-histories allow merging unrelated histories Options related to fetching --all fetch from all remotes -a, --append append to .git/FETCH_HEAD instead of overwriting --upload-pack <path> path to upload pack on remote end -f, --force force overwrite of local branch -t, --tags fetch all tags and associated objects -p, --prune prune remote-tracking branches no longer on remote --recurse-submodules[=<on-demand>] control recursive fetching of submodules -j, --jobs[=<n>] number of submodules pulled in parallel --dry-run dry run -k, --keep keep downloaded pack --depth <depth> deepen history of shallow clone --unshallow convert to a complete repository --update-shallow accept refs that update .git/shallow --refmap <refmap> specify fetch refmap その後、git push -u origin --all を実行してもうまくいきませんでした。。。 以下のレスが帰ってきました。 To bitbucket.org:kouta1612/hello_app.git ! [rejected] master -> master (non-fast-forward) error: failed to push some refs to 'git@bitbucket.org:kouta1612/hello_app.git' hint: Updates were rejected because the tip of your current branch is behind hint: its remote counterpart. Integrate the remote changes (e.g. hint: 'git pull ...') before pushing again. hint: See the 'Note about fast-forwards' in 'git push --help' for details. エラーとなる原因がわからないです。 どうかご教授下さい。よろしくお願いします。
CHERRY

2018/03/25 02:14

すいません。 2回目のコマンドですが、「git push -u origin master」の書き間違いです。回答も訂正しましたので、再度、確認してみていただけないでしょうか。
kouta1612

2018/03/26 11:05

他の方のコマンドで出来ました。 ありがとうございました
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問