お久しぶりです。
mercurialからgitに移行~CI導入までを記事にすることを前季の目標にしてしまったため、git(github)移行する記事です。
(どこかで見たような言い回しだ)
これが振り返り駆動ってやつですね。よくわかりました。
この記事はレベルが高くないので上級者は気分を害する恐れがあります。
決して煽りではない。
で、今回のゴールは bitbucket(mercurial) の https://bitbucket.org/crohaco/decimalize という謎ライブラリをgithubに移すところです。
ではさっそく(ご覧になる方はつっこまずに冷ややかな目で見守ってください)
[vagrant@localhost ~]$ sudo yum -y install mercurial # mercurialインストールしてー Loaded plugins: fastestmirror base | 3.6 kB 00:00 extras | 3.4 kB 00:00 updates | 3.4 kB 00:00 Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp Resolving Dependencies --> Running transaction check ---> Package mercurial.x86_64 0:2.6.2-4.el7 will be installed --> Finished Dependency Resolution Dependencies Resolved ================================================================================ Package Arch Version Repository Size ================================================================================ Installing: mercurial x86_64 2.6.2-4.el7 base 2.6 M Transaction Summary ================================================================================ Install 1 Package Total download size: 2.6 M Installed size: 12 M Downloading packages: mercurial-2.6.2-4.el7.x86_64.rpm | 2.6 MB 00:06 Running transaction check Running transaction test Transaction test succeeded Running transaction Installing : mercurial-2.6.2-4.el7.x86_64 1/1 Verifying : mercurial-2.6.2-4.el7.x86_64 1/1 Installed: mercurial.x86_64 0:2.6.2-4.el7 Complete! [vagrant@localhost ~]$ hg clone https://bitbucket.org/crohaco/decimalize decimalize-hg # 移行するリポジトリを別名で持ってきてー requesting all changes adding changesets adding manifests adding file changes added 6 changesets with 14 changes to 9 files updating to branch default 8 files updated, 0 files merged, 0 files removed, 0 files unresolved [vagrant@localhost decimalize]$ sudo yum -y install git # gitすでに入っててー Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.iij.ad.jp * extras: ftp.iij.ad.jp * updates: ftp.iij.ad.jp Package git-1.8.3.1-6.el7_2.1.x86_64 already installed and latest version Nothing to do [vagrant@localhost ~]$ git clone git://repo.or.cz/fast-export.git # 移行ツールcloneしてー Cloning into 'fast-export'... remote: Counting objects: 2346, done. remote: Total 2346 (delta 0), reused 0 (delta 0) Receiving objects: 100% (2346/2346), 382.72 KiB | 112.00 KiB/s, done. Resolving deltas: 100% (861/861), done. [vagrant@localhost ~]$ mkdir decimalize # 移行先のローカルリポジトリ作ってー [vagrant@localhost ~]$ cd decimalize [vagrant@localhost decimalize]$ git init Initialized empty Git repository in /home/vagrant/decimalize/.git/ [vagrant@localhost decimalize]$ ../fast-export/hg-fast-export.sh -r ../decimalize-hg/ # 移行してー master: Exporting full revision 1/6 with 2/0/0 added/changed/removed files master: Exporting simple delta revision 2/6 with 1/0/0 added/changed/removed files master: Exporting simple delta revision 3/6 with 0/1/0 added/changed/removed files master: Exporting simple delta revision 4/6 with 0/1/0 added/changed/removed files master: Exporting simple delta revision 5/6 with 6/2/1 added/changed/removed files master: Exporting simple delta revision 6/6 with 0/1/0 added/changed/removed files Issued 6 commands git-fast-import statistics: --------------------------------------------------------------------- Alloc'd objects: 5000 Total objects: 27 ( 0 duplicates ) blobs : 14 ( 0 duplicates 1 deltas of 13 attempts) trees : 7 ( 0 duplicates 4 deltas of 7 attempts) commits: 6 ( 0 duplicates 0 deltas of 0 attempts) tags : 0 ( 0 duplicates 0 deltas of 0 attempts) Total branches: 1 ( 1 loads ) marks: 1024 ( 6 unique ) atoms: 9 Memory total: 2344 KiB pools: 2110 KiB objects: 234 KiB --------------------------------------------------------------------- pack_report: getpagesize() = 4096 pack_report: core.packedGitWindowSize = 1073741824 pack_report: core.packedGitLimit = 8589934592 pack_report: pack_used_ctr = 12 pack_report: pack_mmap_calls = 6 pack_report: pack_open_windows = 1 / 1 pack_report: pack_mapped = 5427 / 5427 --------------------------------------------------------------------- [vagrant@localhost decimalize]$ git log --oneline # できてそう f1973e1 update .hgignore bdabdda update structure 7114ff7 support old python-version. f79183d README.md edited online with Bitbucket 1a80534 README.md edited online with Bitbucket 3f4bc26 initialize
sshの設定は以下のようにしました。
[vagrant@localhost ~]$ ssh-keygen Generating public/private rsa key pair. Enter file in which to save the key (/home/vagrant/.ssh/id_rsa): /home/vagrant/.ssh/github.pem Enter passphrase (empty for no passphrase): Enter same passphrase again: Your identification has been saved in /home/vagrant/.ssh/github.pem. Your public key has been saved in /home/vagrant/.ssh/github.pem.pub. The key fingerprint is: 43:23:fd:7d:f5:34:a6:ff:40:80:30:8a:87:1a:3c:35 vagrant@localhost.localdomain The key's randomart image is: +--[ RSA 2048]----+ | | | . | | . o. | | + o..oo | |..*oo.oES | |.=.ooo. | | O +o | | o = . | | . | +-----------------+ [vagrant@localhost ~]$ mv ~/.ssh/github.pem.pub ~/.ssh/github.pub # 拡張子変えてー(お好みで) [vagrant@localhost ~]$ cat << EOF >> ~/.ssh/config > Host github.com > HostName github.com > User git > IdentityFile ~/.ssh/github.pem > Port 22 > EOF [vagrant@localhost ~]$ cat << EOF >> ~/.gitconfig # gitconfig書いてー > [user] > name = righ > email = righ.m9@gmail.com > EOF [vagrant@localhost ~]$ cat ~/.ssh/github.pub ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDJJ4HjLqNZSWtY4jzE4oTGILjplQXNEzI020NXGEQGgKu0qw3Q2tXP/ZopB8Ge5byzT1OYrfhf6I/m6kzh+1WbC/Vk6GHQgaRxUAW0Fiifz0b9Rhkp6Bjp46NwtZtJkjQ5qw0GrD5zG2ijziT3V8SIBsx3zDHogIlkGZfuDw9ttN8N1Ve/7B7qhFSiK4JR5jGB+0tZjoMrmHmgv6OJ1X1ZhL7KHeZzoPzgiLLQzaeCAW3s+JB4UMsE3y8CjlxIn22EHCpOdCp5XmZeqUjdkQiLwIwrM3jdgTPCeo/zCg+hg4zwxiGrQZddUV4YS7WCjofvgTJc1xI8UVPX14HrDCoj vagrant@localhost.localdomain
ちょっとだけgithub上での操作が必要です。 まずは公開鍵の登録。
Settings > SSH and GPG keys > New SSH Key から公開鍵を登録。 |
|
できるとこんな感じになります。 |
|
続いてリポジトリの作成(New repository)。 |
|
完成するとおなじみの画面が。 そして、ここで ... or import code from another repository というのがあることに気付く。 え、なにこれは。こんなの前からあった? とりあえず試してみることに。 |
|
もってきたい https://bitbucket.org/crohaco/decimalize を入力。 |
|
なんか始まった(((( ;゚д゚))) |
|
終わった。 |
|
インポートできてるみたい |
なんだよ、超易しい。何をやってたんだ俺は。
まぁでも、githubから見えないプライベートリポジトリの場合もあるだろうし(震え声)、続きをやっておきましょう。
リモートリポジトリ登録してpushするだけですが。
[vagrant@localhost ~]$ ssh -T git@github.com # 疎通確認OK Warning: Permanently added the RSA host key for IP address '192.30.252.121' to the list of known hosts. Hi righ! You've successfully authenticated, but GitHub does not provide shell access. [vagrant@localhost decimalize]$ git remote add origin git@github.com:righ/decimalize.git [vagrant@localhost decimalize]$ git push origin master Everything up-to-date
(push)できてないけど(設定は)できてるみたいです。なので終了。 みなさんも快適なgit(github)ライフを。
あ、興味がある方は decimalize をよろしくお願いします。(軽いバグあるけど)