Git submodules — exclude specific files/directories

git, git-submodules, github

Solution

In my submodule I had an `/examples` folder I wanted deleted locally to prevent those files being seen by an autogenerated makefile; `origin` had to remain oblivious to the deletion.

In git CLI:

`git update-index --assume-unchanged <path/to/file>`

To track local changes once again:

`git update-index --no-assume-unchanged <path/to/file>`

Or in SourceTree, create a custom action as per Fabian Blechschmidt's answer.

NOTE This is not the same as "Stop tracking", where `origin` will indeed also stop tracking the file on commit - not what you want.

Problem

I'm attempting to use Gits 'submodules' feature to include 3rd party code in a project. I only need a couple of files from the submodule and wish to exclude all the docs, etc that come with it. How can I do this?

Original source

Related problems