Skip to content

Instantly share code, notes, and snippets.

@cjtu
Created March 12, 2021 21:23
Show Gist options
  • Save cjtu/74a38e1ad066e714218762b910d0910e to your computer and use it in GitHub Desktop.
Save cjtu/74a38e1ad066e714218762b910d0910e to your computer and use it in GitHub Desktop.
Make a new repo with CookieCutter

How to make a repo from a template with CookieCutter

  1. Sign up for a GitHub account here
  2. Install cookiecutter with pip/conda/apt-get instructions here
  3. Choose a cookiecutter template (search on GitHub here)
  4. Get the link to the cookiecutter repo that ends in .git (should be in the template install instructions)
  5. Run cookiecutter reponame.git (e.g. cookiecutter https://github.com/mgancita/cookiecutter-pypackage.git)
  6. Follow the prompts to set the options for your new template folder (your name, the repo name, etc.)
  7. Change directory to your new empty template (cd new-repo-name)
    • Run ls to check out the file/folders it made
    • Your code goes in /new-repo-name/new-repo-name/mycode.py
    • Your documentation goes in /new-repo-name/docs/
  8. Make your folder into a git repository with git init
  9. Add and commit the template files/folers as your first commit
    • git add .
    • git commit -m "Set up repo with cookiecutter"
  10. Go to GitHub, click + "make a new repository", call it the same thing as your cookiecutter folder (e.g. new-repo-name)
  11. Now follow GitHub's instructions to push your new repository to GitHub. Back in the terminal type:
    • git add remote <blah>
    • git push -u origin main
    • refresh the page to see your brand new repo on GitHub
  12. (optional) If you used the template above or another one that "Makes a GitHub Pages site with GitHub Actions" then:
    • Go to repository settings
    • Scroll down to GitHub Pages
    • Publish branch gh-pages
    • Go to username.github.io/new-repo-name to see your documentation site
    • You can of course wait to do this step until you write the documentation for your code
    • Note that even if your repo is private this site will be live publicly as soon as you publish the branch in GitHub settings
    • Since the template set up GitHub actions for you, this will update each time you update the /docs/ and push to GitHub
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment