Skip to main content
Background Image
  1. Posts/

git sparse-checkout enable and disable

·127 words·1 min· ·
Xianpeng Shen
Author
Xianpeng Shen
Table of Contents

This post just a note to myself and it works on my environment. it has not been widely tested.

Enable git sparse-checkout
#

Just in my case, I cloned a git repo exists problems on the Windows platform with some folder, in order to work on the Windows platform we get a work around solution as following:

Case 1: when you not already cloned a repository

mkdir git-src
cd git-src
git init
git config core.sparseCheckout true
echo "/assets/" >> .git/info/sparse-checkout
git remote add origin git@github.com:shenxianpeng/shenxianpeng.git
git fetch
git checkout master

Case 2: when you already cloned a repository

cd git-src
git config core.sparseCheckout true
echo "/assets/" >> .git/info/sparse-checkout
rm -rf <other-file/folder-you-dont-need>
git checkout

Disable git sparse-checkout
#

git config core.sparseCheckout false
git read-tree --empty
git reset --hard

Related

Git Commit Squash
·226 words·2 mins
How to squash multiple Git commits into a single commit, both locally and remotely, using interactive rebase and merge strategies in Bitbucket.