Another Way to Create a GitHub Repository

Saturday, February 4, 2017
By: Matthew Doucette

I was having troubles pushing a local project to a new GitHub repository. I could set up a repo on GitHub no problem, however I could not sync it with a local repo. Check out the following two methods:


Ideal Method (Which Failed for Me):

Here is what failed for me:

  1. Create repo on GitHub, then come back to local Git Shell:
  2. git init
  3. git add *.*
  4. git commit -m "Initial commit"
  5. git remote add origin<user>/repo
  6. git push origin master

The "git push" would fail with the following error:

~<path> [master +1076 ~0 -0 !]> git push origin master
! [rejected] master -> master (non-fast-forward)
error: failed to push some refs to '<user>/repo'
hint: Updates were rejected because the tip of your current branch is behind
hint: its remote counterpart. Integrate the remote changes (e.g.
hint: 'git pull ...') before pushing again.
hint: See the 'Note about fast-forwards' in 'git push --help' for details.

I would try to do a "git pull" to fix it, but it would fail with an error I did not record. Contact me if you run into this same issue.


Alternative Method:

Here is an alternate method, proposed by friend Wayne Muise of MudMonger Games. Three steps:


Prepare empty folder:

  1. Move your local project to another folder.
  2. Create an emtpy folder where you want your project to go.


Create repo on GitHub:

  1. Visit
  2. Login; I log in via my "Xona Games" company account -- so it owns the repo -- and access it via my personal "Xonatron" account.
  3. Click "New repository"; You will see it above a list of your existing repositories, if you have some.
  4. Name the repository; Keep in mind that spaces become dashes; It will show you; Example, Infinite Ammo became "Infinite-Ammo"; I am not sure if it causes issues, however I recommend not ending in periods, as Windows cannot create folders that end in periods. In the case of The Exploration Thereof..., it became "The-Exploration-Thereof..." with the periods intact, however I decided against it and removed the periods.
  5. Leave "Description" blank; You can edit this afterwards.
  6. Choose "Private", unless you wish to publicly share your repository; The "Private" option may be reserved only to paid subscriptions to GitHub, as we have.
  7. Enable "Initialize this repository with a README"; It will create a "" file; If you do not choose this, you can likely create one later.
  8. If you are using Unity or another supported engine/platform/codebase:
    1. Click "Add .gitignore: None" dropdown box.  
    2. Scroll down and click on "Unity".
    3. "Add .gitignore: Unity" should appear.
  9. Click "Create repository".
  10. "Creating repository..." should appear.
  11. You should be brought to your new repository; In the case of The Exploration Thereof..., it brings me to:, which should be private; You should see your "" populated with your project title.
  12. Click "Clone or download" dropdown box.
  13. Copy the web URL; In the case of The Exploration Thereof..., it is ""; There is a convenient icon that copies it automatically.
  14. Invite your personal account -- if you have one -- as a contributor.


Add local project to repository via local Git Shell:

  1. Load Git Shell.
  2. Note: In GitHub Desktop, make sure you are logged in as the same user (my "Xona Games" company account for me, not my personal "Xonatron" account); Under options, I have it set so "Xona Games" is the main account, yet "Xonatron" is the account used for commits.
  3. Change directory to folder in question (the empty folder you wish your project to exist in).
  4. Note: The idea here is to move your project into the folder after you download the GitHub repo into the empty folder.
  5. git clone<user>/repo .
  6. Note: This downloads the "origin" branch on GitHub to your local "master" branch on your computer, into your empty folder. You should see your readme file and .gitignore locally if you have chosen to create them. You will also get a .git folder. Note the dot, ".". Without the dot, it creates a folder. With the dot, it downloads to the current folder. If you make a mistake, you can delete the local mistake (delete the files via Windows Explorer) and do it again.
  7. Note: Now the folder is no longer empty. It created it's own folder, which has git files in it, including a ".git" folder, ".gitignore" file, and a "" file.
  8. Test: Run "dir" and you should see "[master ≡]" appear. This is good!
  9. Copy local project into this (now not emtpy) folder where you want your project to go.
  10. Note: Git will think you just made all these project files and treat them as new.
  11. git add *.*
  12. git commit -m "Initial commit"
  13. git push origin master
  14. Note: You could also use "git push -u origin master" and, with using "-u", never have to specific "origin master" again.
  15. Done!
  16. Test: Go to and go to your commits; In the case of The Exploration Thereof..., it is; You should see an "Initial commit" from your company account and a second commit that you just pushed; Plus, all your files should be uploaded to your git repository. Check and see!


If you really wish to be certain, download your repo to a new folder and see if your project can be built again. This way, you know you have all you need on Git.


That is all!



About the Author: I am Matthew Doucette of Xona Games, an award-winning indie game studio that I founded with my twin brother. We make intensified arcade-style retro games. Our business, our games, our technology, and we as competitive gamers have won prestigious awards and received worldwide press. Our business has won $190,000 in contests. Our games have ranked from #1 in Canada to #1 in Japan, have become #1 best sellers in multiple countries, have won game contests, and have held 3 of the top 5 rated spots in Japan of all Xbox LIVE indie games. Our game engines have been awarded for technical excellence. And we, the developers, have placed #1 in competitive gaming competitions -- relating to the games we make. Read about our story, our awards, our games, and view our blog.