In this tutorial, you will learn to move a directory from a Git repository to a new Git repository.

Move Directory to a New Git Repository

Follow the below steps to move a folder from an existing repository to a new repository. Congratulations, You have successfully copied a directory to a new Git repository.

SUB_DIRECTORY_NAME: The relative path to the directory within the project files, you need to separate from others. BRANCH_NAME: Select the branch name from which the directory will be filtered, like “main”, “master”, “develop” etc.

Once the above command executed successfully, you will see that the current directory has only files that were in the subdirectory.