The first step is to create an orphan branch, let’s name it new-repo

$ git checkout --orphan new-repo

The orphan branch does not have any ancestry so it is the closest thing to a new repo you will have. All the existing content will be in the directory so you need to remove it.

$ git rm -rf *

Next you need a initial commit to 'persist' this branch

$ git commit --allow-empty -m "Initial commit"

And now to the important part, extract a range of commits into your new branch

$ git rebase --onto new-repo --committer-date-is-author-date <initial_commit_predecessor> <final_commit>

Just remember to consider the predecessor which is the commit before the commit you want to start your new repo. This will bring all your changes back to the file system. Next you need to fast forward the new repo to HEAD

$ git rebase HEAD new-codebase

This completes the first step. Now we have a branch that represents the new repository by itself. The next step is to export it to an external git repository. There are several ways to do it. The bundle is a very clean and easy solution.

$ git bundle create /tmp/new-repository.bundle new-repo

The bundle file is the repo itself, you can clone it

$ git clone /tmp/new-repository.bundle new-application

You will receive a couple of messages complaining that HEAD refers to nonexistent ref, it is fine because master is empty. Go to your new cloned repository (called new-application) and

$ git merge new-repo

This will be a merge the branch into an empty master so all your changes are going to be accepted without conflicts.

Last but now least, get rid of the temporary branch

$ git remote remove origin

Now this repo is ready to have its own life.