Convert a folder in Git repository into a new Git repository

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:

Convert a folder in Git repository into a new Git repository

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

Convert a folder in Git repository into a new Git repository

Next, we will execute the following statement:

<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:

Convert a folder in Git repository into a new Git repository

Put this folder to root:

Convert a folder in Git repository into a new Git repository

Then continue with the following statements:

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:

Here we have completed the conversion, the results are as follows:
Convert a folder in Git repository into a new Git repository

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.

 

Add Comment