The following steps requires that your existing code is in a GitHub repository.
-
Follow the instructions to create a new package with the Python template, while answering the questions like you would for the existing package.
-
Create a Git structure for the new directory: (replace
<NEW_DIRECTORY>
with directory name you used during cookiecutter questionnaire)
$ cd <NEW_DIRECTORY>
$ git init
$ git add --all
$ git commit -m "Added code generated by cookiecutter"
$ git branch -M main
- Import the existing repository from GitHub (Replace
<ORGANIZATION>
with your GitHub organization name ,<REPOSITORY>
with your GitHub repository name and<BRANCH>
with your default branch for examplemain
ormaster
):
$ git remote add -f existing_code https://github.com/<ORGANIZATION>/<REPOSITORY>
$ git fetch existing_code
$ git merge existing_code/<BRANCH> --allow-unrelated-histories
- The previous step will likely result in several merge conflicts. Solve the conflicts by editing the files.
- Once all conflicts have been resolved then add all the files to GitHub:
$ git add --all
$ git commit -m "Merged existing code with code generated by cookiecutter"
$ git push