Your question is a little unclear about exactly what you need, but git supports submodule, that allows you to have your repository with one sub-folder that is another repository.
This would allow you to change content just in one sub-folder of your repository, not affecting you root repository.
You could have two repositories, with two branches in each of them:
Repository main-project
main-master
main-dev
Repository library
library-master
library-dev
In the repositories:
- main-master
    - app
    - modules
    - lib  --> git checkout library/lib-master
and
- main-dev
    - app
    - modules
    - lib  --> git checkout library/lib-dev
This structure allows you to checkout main-master and have the correct version of lib sub-folder.
At the same time, if you clone the branch main-dev to another directory, it will bring only the correct content.
To checkout the root branch with the sub-branch, try: git clone <repo>:main-master --recursive
If this is what you need, you can see more about it in Git Documentation.
Or here on StackOverflow.
I'm not sure this is what you're looking for, but I hope it helps.