Skip to content

Commit a075055

Browse files
authored
Merge pull request #243 from NLeSC/202-add-to-existing-project
instructions for applying template to an existing package
2 parents 72678ca + c483d2b commit a075055

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

ADD_TO_EXISTING_PACKAGE.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Add your existing code to directory generated by the NLeSC Python template
2+
3+
The following steps requires that your existing code is in a GitHub repository.
4+
5+
1. Follow the [instructions to create a new package](https://github.com/NLeSC/python-template#how-to-use) with the Python template, while answering the questions like you would for the existing package.
6+
7+
2. Create a Git structure for the new directory: (replace `<NEW_DIRECTORY>` with directory name you used during cookiecutter questionnaire)
8+
```shell
9+
$ cd <NEW_DIRECTORY>
10+
$ git init
11+
$ git add --all
12+
$ git commit -m "Added code generated by cookiecutter"
13+
$ git branch -M main
14+
```
15+
16+
3. 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 example `main` or `master`):
17+
```shell
18+
$ git remote add -f existing_code https://github.com/<ORGANIZATION>/<REPOSITORY>
19+
$ git fetch existing_code
20+
$ git merge existing_code/<BRANCH> --allow-unrelated-histories
21+
```
22+
23+
4. The previous step will likely result in several merge conflicts. Solve the conflicts by editing the files.
24+
5. Once all conflicts have been resolved then add all the files to GitHub:
25+
```shell
26+
$ git add --all
27+
$ git commit -m "Merged existing code with code generated by cookiecutter"
28+
$ git push
29+
```

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ my-python-project/
109109
```
110110

111111
For an explanation of what's there, read on in the [project_setup.md]({{cookiecutter.project_name}}/project_setup.md) file.
112+
There are also instructions on how to [apply the template to an existing Python package](ADD_TO_EXISTING_PACKAGE.md).
112113

113114
## Examples
114115

0 commit comments

Comments
 (0)