LoginSignup
0
0

More than 3 years have passed since last update.

履歴を残したままサブディレクトリをリポジトリに昇格させる

Last updated at Posted at 2020-04-10

前提

git@github.com:mafuyuk/infra.gitというリポジトリが存在し、その配下にインフラ関係のものをサブディレクトリを切り詰め込んでいた(とする)

$ tree -L 1                                                                                                                  
.
├── ansible
├── eksctl
├── k8s
└── terraform

k8sのマニフェストはCI/CDのタイミングなどによって別でリポジトリ立てたいなーけど、履歴もちゃんと持っていきたいなーってときにした対応方法の備忘録

手順

1 GitHubでリポジトリを新規で作成し、URLを取得しておく

ex) git@github.com:mafuyuk/manifest.git

2 履歴を残したままサブディレクトリをリポジトリに昇格させる

$ git remote add manifest git@github.com:mafuyuk/manifest.git                                                       
$ git subtree push --prefix k8s manifest master

3 掃除

$ git remote remove manifest
$ rm -rf k8s
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