LoginSignup
0
0

githubのリポジトリ内の、特定のフォルダのみ手元にcloneする方法

Posted at

cloneするリポジトリ「myproj」は以下のフォルダ構成になっているとする

myproj
|- dir1
|- dir2
|- README.md

cloneしたフォルダを置いておくディレクトリを作成、移動

$ mkdir test1
$ cd test1

gitの初期化、sparse-checkoutの有効化、リモートのリポジトリの登録

$ git init
$ git config core.sparsecheckout true
$ git remote add origin https://github.com/testuser/myproj.git

手元にcloneしたいフォルダを登録(今回はdir1とする)

$ echo "dir1/*" > .git/info/sparse-checkout

手元にpull

$ git pull origin main

最初に作ったtest1ディレクトリ内にディレクトリdir1があれば成功。

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