⛳
GitHubの別リポジトリへの保存備忘録
- ・ブランチを切り替えるコマンド:
git switch(既存ブランチ名)
git switch -b (新ブランチ名)
(switchコマンドでなく、checkoutでも可。)
2. ・push先の変更:
git remote set-url origin [pushしたいurl]
(urlはssh鍵を使用していたなら git@github.com:ユーザー名/リポジトリ名(自分はこれだった))
- ・pushしたいブランチ名を指定してプッシュ:
git push origin [pushしたいbranch名]
3.1 ・git pullをしたところ、下記のエラーが発生(ローカル環境とリモート環境の差が原因?)
hint: You have divergent branches and need to specify how to reconcile them.
hint: You can do so by running one of the following commands sometime before
hint: your next pull:
hint:
hint: git config pull.rebase false # merge (the default strategy)
hint: git config pull.rebase true # rebase
hint: git config pull.ff only # fast-forward only
hint:
hint: You can replace "git config" with "git config --global" to set a default
hint: preference for all repositories. You can also pass --rebase, --no-rebase,
hint: or --ff-only on the command line to override the configured default per
hint: invocation.
fatal: Need to specify how to reconcile divergent branches.
対策
以下のコマンドを入力
git merge --allow-unrelated-histories origin/main
すると以下のような表記がでた
Auto-merging README.md
CONFLICT (add/add): Merge conflict in README.md
Automatic merge failed; fix conflicts and then commit the result.
このあとはいつものadd、commit、pushでどうにかなった
Discussion