Create a new GitHub repository based on a template

This blog post is a simple cheat sheet how to create a new GitHub repository from a GitHub repository template, by not using the guide from GitHub.
In that case we use the template-terraform-gitops GitHub repository. That GitHub repository is a template to build own modules for terraform automations.

Step 1: Clone the project to your local computer

git clone

Step 2: Delete the .git folder in the cloned project to disconnect the git repository

Step 3: Rename the root folder of the project from template-terraform-gitops to gitops-terraform-guestbook

Step 4: Run the git init command in the gitops-terraform-guestbook folder

That will create a new .git folder.

git init
  • Output
hint: Using 'master' as the name for the initial branch. This default branch name
hint: is subject to change. To configure the initial branch name to use in all
hint: of your new repositories, which will suppress this warning, call:
hint:   git config --global init.defaultBranch <name>
hint: Names commonly chosen instead of 'master' are 'main', 'trunk' and
hint: 'development'. The just-created branch can be renamed via this command:
hint:   git branch -m <name>
Initialized empty Git repository in /Users/thomassuedbroecker/Downloads/dev/gitops-terraform-guestbook/.git/

Step 4: Add .DS_Store to the .gitignore file (in case you are using MacOS)


Step 5: Execute the git add --all command

git add --all

Step 6: Create new GitHub project gitops-terraform-guestbook using git commit

git commit
  • Interactive output:

It opens a vi editor.

  1. Enter I
  2. Now you can insert some text Init repo.
  3. Press esc
  4. Press :
  5. Insert wq
# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
# On branch master
# Initial commit
# Changes to be committed:
#       new file:   .DS_Store
#       new file:   .github/.DS_Store
#       new file:   .github/release-drafter.yaml
#       new file:   .github/scripts/
#       new file:   .github/scripts/
#       new file:   .github/workflows/manual-test-repo-delete.yaml
#       new file:   .github/workflows/notify.yaml
#       new file:   .github/workflows/publish-metadata.yaml

Step 7: Create a new empty GitHub repository with the name gitops-terraform-guestbook

That step needs to be done in the GitHub UI.

Step 8: Connect to the newly created GitHub repository

git branch -M main
git remote add origin$USERNAME/$REPONAME

Step 9: Push to the master branch

If you don’t have a ssh key You can also visit may blog post Create a ssh key for your GitLab project on IBM Cloud to inspect how you create and use a ssh key in context with a GitHub repository.

git push -u origin main

I hope this was useful to you and let’s see what’s next?




Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.