In this tutorial, I will guide you all how to convert a folder in a GIT repository into a new GIT repository.
Here, I use Git on Windows.
OK, I have a repository with the following content:

Now, my need is to separate the coffee project directory into a new repository. So how do I do?
We have 5 steps to do this:
First, open Git Bash and navigate to the directory of the repository.
In this example, I will navigate to the webbotsolutions.net directory and open Git Bash

Next, we will execute the following statement:
| 1 | git filter-branch --subdirectory-filter <folder_name> HEAD -- --all | 
<folder_name> is the name of the project directory that you want to migrate to a new GIT repository, to remove all existing folders in current GIT repository.
Here, I will execute the following statement:

Put this folder to root:
| 1 | git reset --hard | 

Then continue with the following statements:
| 1 | git gc --aggressive | 
| 1 | git prune | 
The last step we need to do is to remove the GIT remote repository URL being configured for the current repository with the following statement:
| 1 | git remote rm origin | 
Here we have completed the conversion, the results are as follows:

The current repository is just a local GIT repository, if you want to include it in the remote GIT repository, please refer to this tutorial.
 
 
