ひれおくん

プログラミングをメインで書きます。

github リポジトリ 複製のやり方

実現したいこと

現在、Github上にAというリポジトリがあります。 Aリポジトリの内容をそのままコピーし、新しいリポジトリBを作成したいと考えています。 (コピー後は、AとBでそれぞれ別に運用をしていきます) ※デフォルトブランチ以外のブランチとコミット履歴はいらない

参照:https://teratail.com/questions/31714

git push時のエラー

$ git push
fatal: The current branch master has no upstream branch.
To push the current branch and set the remote as upstream, use

    git push --set-upstream origin master

参照:http://diskogs.hatenablog.com/entry/2014/04/05/151155 -set-upstream オプションをつけるとローカルリポジトリの現在のブランチの上流をorigin master に規定したことになります。

git pushでなくgit push --set-upstream origin masterを実行して解決

全てのブランチとコミット履歴を引き継ぎたい場合

git clone --mirror git@github.com:a.git hoge
cd hoge/
git remote set-url origin git@github.com:b.git
git push --mirror origin

参照:https://teratail.com/questions/31714