Split subtree

Consider you have the following repo:

.
├── resources
│   ├── default.css
│   └── main.css
└── src
    └── run.sh

and the git history is:

commit 3010
    Default css

commit da1d
    Added hashbang

commit 7cd1
    Initial commit

and you want to get the git history of only the src directory, then you can get it by splitting the git tree:

git subtree split --prefix src

commit 44a3
    Added hashbang

commit 69ec
    Initial commit

Note

The split subtree command generates a synthetic log history. You can see that the commit hashes do not match.