GitHub Account and Repository
Create a free GitHub account and your first online repository.
GitHub hosts Git repositories in the cloud so you can back up, share, and collaborate. Sign up for free at github.com.
Create a repository
- Click the + in the top-right and choose New repository.
- Give it a name and choose Public or Private.
- Optionally add a README, a
.gitignore, and a license. - Click Create repository.
GitHub then shows the commands to connect an existing local repo or clone the new one.
Example
# GitHub shows these after creating an empty repo:
git remote add origin https://github.com/you/my-project.git
git branch -M main
git push -u origin mainWhen to use it
- A developer creates a public GitHub repo to share an open-source library so others can star, fork, and contribute.
- A startup creates a private repo to host their product codebase, granting access only to team members.
- A student creates a repo to showcase portfolio projects, linking it on their resume for recruiters to browse.
More examples
Create a repo with GitHub CLI
Uses the official GitHub CLI to create a remote repository without opening a browser.
# Install and authenticate GitHub CLI first
gh auth login
# Create a new public repo
gh repo create my-portfolio --public --description "My dev portfolio"Push existing local repo to GitHub
Connects a local repo to the new GitHub remote and pushes the initial commit history upstream.
# After creating the repo on GitHub
git remote add origin https://github.com/username/my-portfolio.git
git branch -M main
git push -u origin mainClone your new repo fresh
Clones the GitHub repo to a new local directory and confirms the commit history arrived correctly.
gh repo clone username/my-portfolio
cd my-portfolio
git log --oneline
Discussion