Git: Untracking folder only specific branch

I have a question regarding using a git.

On my “Test” branch, I want to let my git untrack a folder and its sub-files by using the below command. and want to delete this folder in order to improve the build time. (There are over 4000 files and images in the folder and it makes my working branch too slow in building)

git ls-files -z PathToFolder | xargs -0 git update-index --assume-unchanged

It works okay, when I just work on this branch. But the problems is when switching to another branch because the deleted folder is not recovered.

What I want

  • I want to untrack a folder containing lots files and delete it for I want to improve the jekyll build speed when I am on “Test” branch only, but not other branch.
  • When switching to another branch, the deleted folder should be back.

Thank you for reading :slight_smile:

Can you add a step to your jekyll build to trim the rirectory (or contents) before building?

So, change jekyll/process instead of changing git/repo.