ShunjiM
@ShunjiM (Shunji M)

Are you sure you want to delete the question?

Leaving a resolved question undeleted may help others!

GitHubレポジトリの切り替え方法

Q&A

Closed

解決したいこと

git push origin master

で表示される

'https://github.com/⬢⬢⬢/●●●.git'

を別のリポジトリの

'https://github.com/●●●●/▲▲▲▲.git'

に切り替えたいのですが、わからないので、
教えて頂きたいと思います。

0

3Answer

リポジトリとは通常「切り替える」ものではありません。
目的は何ですか?

0Like

Comments

  1. @ShunjiM

    Questioner

    そうなのですね、すみません。

    ```bash
    ! [rejected] master -> master (fetch first)
    error: failed to push some refs to 'https://github.com/●●/▲▲▲▲.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.
    hint: See the 'Note about fast-forwards' in 'git push --help' for details.
    ```
    のエラーが出たので、、
  2. 何をやりたいのか不明なのでアドバイスできませんが、こちらのサイトをざっと眺めてみるといいと思います。

    [サル先生のGit入門〜バージョン管理を使いこなそう〜【プロジェクト管理ツールBacklog】]
    https://backlog.com/ja/git-tutorial/

! [rejected] master -> master (fetch first)

のエラーについては原因によって直し方も変わるので、リポジトリを切り替えることで直るとは限りません。一般的にはマージすれば直ります。以下の手順を見てください。

もし元のリポジトリ 'https://github.com/⬢⬢⬢/●●●.git' が移転して別の URL 'https://github.com/●●●●/▲▲▲▲.git' になったということなら切り替えが必要です。その場合は

git remote set-url origin 'https://github.com/●●●●/▲▲▲▲.git'

を実行してください。

0Like
git push origin master

実行後にUsernameとPassword入力後に、

 ! [rejected]        master -> master (fetch first)
error: failed to push some refs to 'https://github.com/⬢⬢⬢/●●●.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.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

と言うエラーが出ているので、リポジトリを切り替える事で対処出来るのかなと思っていました。

0Like

Your answer might help someone💌