How to disable sparse check after power on?

I allowed a rare check

git init git remote add <url> git config --global core.sparseCheckout true echo "assets" >> .git/info/sparse-checkout git pull origin master 

Git checked only for me the asset folder

But now I want to enable checkout folders / files again, but it does not work.

1) first disabled configuration

 git config --global core.sparseCheckout false 

2) deleted entries in .git / info / sparse-checkout

But git did not check any other folders / files for me, it seems that it sticks to the "assets" folder.

Can someone tell me how can I reset / disable this sparse check without creating a new repo.?

+6
source share
2 answers

You can see an example of "canceling" a rare check in this script from Roscoe A. Bartlett:

git read-tree .

 echo "Undoing sparse checkout" # Get the full tree back echo "*" > $SC_FILE git config core.sparsecheckout true git read-tree --reset -u HEAD # Wipe out all traces of sparse checkout support rm $SC_FILE git config core.sparsecheckout false 

The Adventure in Git - SparseCheckouts article by Rich Somerfield offers a similar option (also valid for submodules):

 echo "/*" > .git/info/sparse-checkout echo "/*" > .git/modules/<MODULEPATH>/info/sparse-checkout git read-tree -mu HEAD git config core.sparseCheckout false 

braham-snyder adds in the comments that updating a .git/info/sparse-checkout (for checking and tracking additional files) can be achieved with

 git read-tree --dry-run HEAD 
+7
source

While VonC's answer is definitely correct and will help with the inevitable problem, I feel the need to develop and explain the underlying problem.

Background

Git sparse-checkout uses the skip-worktree bit , which basically tells git to consider the file in your working directory will be "up-to-date", regardless of the true state.

When using sparse-checkout git, this bit will be applied to all files that do not match the patterns described in your sparse-checkout file. If you disable sparse-checkout or delete the template file, these bits will still be set and the files will not be returned. You can read about it here.

Thus, you must remove the skip-worktree manually from the corresponding files. The simplest approach, of course, is the VonC proposal.

But why?

The rationale for this is quite simple. The skip-worktree not used exclusively for sparse-checkout , but rather as a tool in the git toolbox. Other processes use the same bit, or the user can even use it on their own (I personally use it regularly to ignore changes in configuration files when debugging).


In the side pointer . In fact, you can get a list of files marked as skip-worktree bits using git ls-files -v . This will display all files under version control; files with the skip-worktree are prefixed with S

If you only want to list the skip-worktree with the flag, you can easily parse the grep list with the following command: git ls-files -v | grep '^S' | cut -d' ' -f2 git ls-files -v | grep '^S' | cut -d' ' -f2 git ls-files -v | grep '^S' | cut -d' ' -f2 .

+5
source

All Articles