How to create a new Public repository on GitHub so you can:
- start coding on your development computers.
- track revisions to your code and restore if needed,
- share your open source code with the world, or a small team of developers.
All of this, without using the command line.
There are lots of great reasons to use GitHub to share a repository of your code, like:
- using git to develop a WordPress site with a team of coders
- working on your own open source project and share your code with contributors
- learning how to use git to track changes to your code.
What you need
Before you start, be sure that you:
- Have a GitHub account set up correctly.
- Know what language you want to use to develop your project.
Git repositories (also called a “repo”) are easier to manage if you select a single development language.
Your public repository needs an open source license
These steps assume that you want to create a public repo, which means that anyone can view your code. This is ideal if you want to release your code as an open source project.
An open source project must include an open source license. We recommend the MIT License to get started. According to GitHub, the MIT License is:
A short and simple permissive license with conditions only requiring preservation of copyright and license notices. Licensed works, modifications, and larger works may be distributed under different terms and without source code.
You may want to select a more restrictive license, like the GPL, but that’s a topic for another post.
Or, you may want to keep your repository private, in which case you don’t need a license.
The steps to create a private repository are therefore slightly simpler than the steps described here to create a public repo.
Create a new public repository on GitHub
To get started, log into GitHub.
- In the upper right corner, next to your avatar, click [+] and then select New repository. The Create a new repository page will open.
- Name your repository.
- Write a short description. This will automatically appear in your new README.md file.
- Select Public, since this is an open source project.
- Select Initialize this repository with a README.
- Recommended – Add .gitignore: select your development language.
- Recommended – Add a license: MIT License
- Click [Create repository]
At this point, your new repo contains three files:
.gitignore— tells Git to ignore certain files, like temp and cache files, that you don’t want to include in your repo.
LICENSE— contains the text of your actual open source license, including your name that you used to set up your GitHub account.
README.md— this file is the primary project documentation. Use it to:
- describe your project,
- list a version history,
- keep important developer notes,
- add links to other resources (like a project wiki and additional documentation).
Now that your repo has at least one file, you can clone your repo to a local development computer.
When you clone a repo, you can also create a branch. For more information on how to use branches (especially if you’re coding with others), review Hello World (GitHub Guides).
Let’s keep it simple for now so you can:
- start coding right away on your favorite development computer, and
- use Git to track all the changes you make to your code.
Clone your new public repository
After you create a new public repository on GitHub, you need to clone it so you can work with it on your local development computer.
In addition, you can apply these steps to clone any public repository on GitHub, too — not just repos that you create.
Cloning a repo means you’re going to create a full copy of all the data in your repo — not just the code, but all of the different versions of the files contained within.
Cloning a repo also means that you can contribute code back to the repo.
If you just want to look at code in a repo, and maybe play around with it on your computer, then you can simply download a ZIP of the current state of the code files.
Downloading a ZIP, however, means you
- you don’t receive a copy of the version history,
- it doesn’t allow you to use git to update the repo with your changes.
Therefore, you want to clone your project so you can use git to:
- track all the changes you make to your code
- work with branches
- collaborate with other developers
So: clone your new repo to take advantage of all the features git has to offer.
Select a connection type for your repo
You can clone a GitHub repository using two types of connections: HTTPS and SSL. Both are secure, encrypted connections.
HTTPS is easier to use, because:
- You typically won’t run into a firewall blocking HTTPS connections.
- You can use the handy GitHub Desktop app to clone your repo — no need to use the command line.
To learn more about the differences between HTTPS and SSL connections to your GitHub repo, read Which remote URL should I use?.
Also, you can always change your mind later and switch from HTTPS to SSL. For details, learn how to change a remote repo’s URL and connection type.
Finally, If you are comfortable working at the command line, or you’d like to understand the specific git commands you need to clone a repo, check out Getting a Git Repository.
To keep things simple for now, we’ll use the GitHub Desktop app to clone a public GitHub repo.
Clone your new public repository with GitHub Desktop
First, download the GitHub Desktop app to your Windows or Mac development computer.
Note: if you’re using Linux as your development platform, GitHub Desktop isn’t available. But, you can select from a number of other Git GUI Clients.
If you’ve followed the steps above to create a new public repo, you’ll have your new repo open in your browser.
If not, just log into GitHub and click the repo name you want to clone to your computer. Or, find any other public repo you want to clone.
Then, on the repo’s main page:
- Click the big green [Clone or download] button.
- Select either SSH or HTTPS as your connection protocol. I prefer SSH, but HTTPS is easier to start with (no SSH key required).
- Click the [Open in Desktop] link that appears.
- Your browser may display a Launch Application window.
- The GitHub Desktop app opens and displays the Clone a repository dialog box.
- Review the Local Path proposed for your new repo. If you’d like to change it, click [Choose…] and select the folder that you want to contain your new repo. In other words, your new repo will appear as a folder inside of the folder you selected.
- Once you’re satisfied, click [Clone].
After that, the GitHub Desktop app will display a progress indicator, then the contents of your new repo. You’ll also see some handy buttons to:
- launch your favorite code editor
- view the files in the repo on your local computer
- view your repo on GitHub.com
Adding files and code to your new public repository on GitHub
Now that you’ve set up a repo on your local development computer, you can start coding, or add existing files.
Add existing files
Use your favorite file management tool (such as the Mac Finder, Windows Explorer, the command line, whatever) to move files into your new repository folder. Then:
- open GitHub Desktop,
- commit the files to your repo,
- (optional) add a comment,
- push the changes to your master branch on GitHub.
So, you don’t have to use the command line to work with your repository, even after you start coding.
When you open a folder that’s also a clone of a git repo, your code editor will automatically recognize that the folder is a git repo, because of the hidden .git folder contained inside.
Then, you can fetch, commit, push, and pull your code to your repo branches in your code editor. All of this without having to enter any commands at the command line.