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

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

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

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

BitBucket

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

Q&A

解決済

1回答

3585閲覧

git を bitbucketにpush したいですが、間違っていれてしまったのでできません。

bouyomisan

総合スコア87

Git

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

BitBucket

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

1グッド

0クリップ

投稿2017/03/29 07:04

git のコードを保存したいので

(master) $ git remote add origin git@bitbucket.org:username/second_repo.git

とすると

git

1 $ git push 2Warning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of known hosts. 3 4To bitbucket.org:user/first_repo.git 5 ! [rejected] master -> master (non-fast-forward) 6 7error: failed to push some refs to 'git@bitbucket.org:user/first_repo.git' 8hint: Updates were rejected because the tip of your current branch is behind 9hint: its remote counterpart. Integrate the remote changes (e.g. 10hint: 'git pull ...') before pushing again. 11hint: See the 'Note about fast-forwards' in 'git push --help' for details.

とでたので指示どおりすると

toy_app (master) $ git pull origin master Warning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of known hosts. From bitbucket.org:user/first_repo * branch master -> FETCH_HEAD fatal: refusing to merge unrelated histories

というエラーがでました。たしかに first_repo とうのに入っているコードといま入れたいコードは全くべつものだということを思い出したので新しくbitbucket でsecond_repo というのをつくり、ためしましたがエラーがでました。

git

1 (master) $ git remote add origin git@bitbucket.org:user/second_repo.git 2 3fatal: remote origin already exists.

origin というのは2回使えないというので second_origin として試しました。

(master) $ git remote add secondorigin git@bitbucket.org:user/second_repo.git

エラーがでなかったのでもう一度 git push したらはじめと同じエラーがでました。

git

1 $ git push 2Warning: Permanently added 'bitbucket.org,104.192.143.1' (RSA) to the list of known hosts. 3 4To bitbucket.org:user/first_repo.git 5 ! [rejected] master -> master (non-fast-forward) 6 7error: failed to push some refs to 'git@bitbucket.org:user/first_repo.git' 8hint: Updates were rejected because the tip of your current branch is behind 9hint: its remote counterpart. Integrate the remote changes (e.g. 10hint: 'git pull ...') before pushing again. 11hint: See the 'Note about fast-forwards' in 'git push --help' for details.

とにかくぼくはコードの保存がしたいです。元の first_repo がきえても構いません。どうしたらいいのでしょうか教えてください。

ikuwow👍を押しています

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

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

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

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

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

guest

回答1

0

ベストアンサー

$ git push secondorigin master

これでどうでしょうか。first_repo がなくてもいいなら、

$ git remote set-url origin git@bitbucket.org:user/second_repo.git

として origin を書き換えても良いかと思います。

投稿2017/03/30 03:31

thinca

総合スコア1864

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

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

bouyomisan

2017/04/09 04:25

できました!ありがとうございます
thinca

2017/04/10 02:18

解決して良かったです。解決しましたら解決済みにしてください。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

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

ただいまの回答率
85.48%

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

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

質問する

関連した質問