0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

これまで運用してきたリポジトリ「A」の履歴を維持して、新規リポジトリ「B」に登録する

Last updated at Posted at 2021-08-15

内容

これまで運用してきたリポジトリ「A」の履歴を維持して、新規リポジトリ「B」に登録する.
ここでは「A」「B」を次として手順を記す.

リポジトリ「A」... GitLab
リポジトリ「B」... GitHub

手順

1. GitHub に登録したい GitLab のリモートリポジトリを clone してくる
$ git clone git@gitlab.com:A/B.git
$ cd zzzz
2. リモートリポジトリ情報を GitHub に書き換える

事前に GitHub 上にリポジトリ「X/Y.git」を作成しておくこと

$ git remote set-url origin git@github.com:X/Y.git
3. push する
$ git push origin master

以上.
 

トラブルと対策

push すると「error: src refspec main does not match any.」が出てしまう

リモートブランチを間違えている.
下記の場合だと「main」ではなくて、「master」が正解であった.

$ git push origin main
error: src refspec main does not match any.
error: failed to push some refs to 'git@github.com:X/Y.git'

$ git push origin master
Counting objects: 24, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (18/18), done.
Writing objects: 100% (24/24), 3.51 KiB | 3.51 MiB/s, done.
Total 24 (delta 5), reused 0 (delta 0)
remote: Resolving deltas: 100% (5/5), done.

 

参考にした情報

https://deepblue-ts.co.jp/git/git-push-error/

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?