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 1 year has passed since last update.

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?