GitHub Repository
Create a GitHub repository, set visibility, write a README that tells a stranger how to clone and run the project, and push the first history.
The GitHub page is not git init
Git Repository created a database on disk. Git Remote taught origin as a name for another location. GitHub Authentication proved GitHub will talk to you. This lesson creates the hosted repository that URL names.
Git repository
Working tree, index, commits, and branch names such as main. git init already did this job.
Hosted repository
A namespace, visibility, browser page, and clone URL. GitHub stores Git objects; the page is not a substitute for git log.
Create empty when you already have commits
# Create an EMPTY hosted repository (no README, license, or .gitignore commit)
gh repo create sovrancode-practice-remote --public --source=. --remote=origin --push
# Confirm Git now has a GitHub URL
git remote -v
git ls-remote origin
git branch -vvgh repo create can create the GitHub repository, add origin, and push in one step when --source=. points at the current folder. Omit any flag that adds a README. The web UI is the same rule: New repository, then uncheck README, license, and gitignore.
Platform-specific screenshots and the empty-create warning also live in the Git and GitHub setup guide. This lesson is the model: empty remote, matching URL, first push you can prove.
Test what you learned
Type the GitHub CLI command that creates a public repository named sovrancode-practice-remote from the current folder and pushes it.
Public and private are audience, not safety
Public
Anyone can clone. Use this for learning repositories you can delete, and for work you intend to show.
Private
Only people you grant can clone. Still never commit tokens. Private is not encryption of history.
Change later
Visibility can move. History that was public may already be copied. Treat publication as one-way for secrets.
Organization repos
Follow employer naming and access rules. This lesson uses a personal disposable repository.
Write a README a stranger can use
# Practice remote
A disposable GitHub repository for learning first push.
## Clone
```bash
git clone https://github.com/OWNER/sovrancode-practice-remote.git
```
## Run
Open README.md. There is no application to start.GitHub renders README.md from Git. The file should say what the project is, how to clone it, and how to run it. A learning repository can say there is nothing to run. Do not paste credentials, private keys, or .env values into the README.
Test what you learned
Type the filename GitHub renders on the repository home page.
Point origin at the new URL
# After New repository on GitHub with every initializer unchecked:
git remote add origin https://github.com/OWNER/sovrancode-practice-remote.git
git remote -v
git push -u origin main
git ls-remote originIf gh repo create --source=. already set origin, skip git remote add. If you used the website, add the URL that matches the method from GitHub Authentication: https://github.com/OWNER/REPOSITORY.git or git@github.com:OWNER/REPOSITORY.git. The browser address bar without .git is the HTML page, not the clone URL.
Test what you learned
Type the command that adds origin pointing at https://github.com/OWNER/sovrancode-practice-remote.git.
Push the first history on purpose
git push -u origin main sends local main and records upstream. After it succeeds, git branch -vv shows [origin/main] and git ls-remote origin lists the same commit GitHub’s page will show. Dirty files you did not commit stay local; the hosted copy only receives objects Git already recorded.
Name the branch. Until upstream exists, Git should not guess. If your local default is not main, push that name and keep GitHub’s default branch consistent later—do not rename in a panic during the first push.
Prove it with a second clone
git clone https://github.com/OWNER/sovrancode-practice-remote.git /tmp/sovrancode-hosted-clone
cd /tmp/sovrancode-hosted-clone
git log --oneline --decorate
git remote -vA second clone is the honest test. If README.md and git log --oneline match what you pushed, the GitHub page is not a special copy—it is another working tree of the same history. Git Remote practiced this with a bare folder; GitHub is the same exchange with a hosted URL.
Diagnose a README that beat you to origin
# GitHub already has a commit you did not make locally
git fetch origin
git log --oneline --decorate --graph --all
# Do not force-push to “make the page match.”
# Next time, create the GitHub repository empty.If GitHub created a README commit, git push -u origin main is a non-fast-forward of two unrelated roots. Fetch and read the graph. Do not start with force-push. The repair for the next repository is empty create. Integrating unrelated histories is a deliberate merge, not a first-publish shortcut.
Guided practice: publish one disposable repo
- 01Commit locally first
In a throwaway folder, write
README.md,git add, and commit. Confirmgit statusis clean. - 02Create empty on GitHub
Use
gh repo createwithout a README flag, or the website with initializers unchecked. - 03Match the URL
git remote -vmust show HTTPS or SSH according to the credential you already proved. - 04Push main
Run
git push -u origin main. Recordgit ls-remote originandgit branch -vv. - 05Clone elsewhere
Clone into
/tmpand confirm the README and the same tip commit.
Independent lab: hosted copy matches local main
- Create a disposable local repository with a README that states clone instructions and that there is nothing to run.
- Create an empty public GitHub repository. Do not add a README, license, or gitignore on GitHub.
- Set
originif the CLI did not, then rungit push -u origin main. - Clone the GitHub URL into a second folder. Show that
git log --onelinematches andREADME.mdis present. - Write four lines: visibility, why the GitHub repo was empty, the push command, and how you proved the hosted copy.
Common repository mistakes
Checking Add a README
That checkbox is a commit. Empty create when local history already exists.
Cloning the browser URL
Clone the Git URL that ends in .git, matching HTTPS or SSH.
Calling the page “the real repo”
The GitHub page is a view. Local commits that never pushed are not there.
Force-pushing the first rejection
Fetch first. For practice, delete and recreate empty rather than rewriting.
Lesson review
You can host a Git repository on GitHub without confusing the page for Git, write a README a stranger can follow, and push the first history onto an empty remote. The next lesson copies someone else’s GitHub repository with a fork.
- I know a GitHub repository is a hosted remote, not
git init. - I create GitHub repositories empty when I already have local commits.
- I can
git push -u origin mainand prove it withgit cloneandgit ls-remote origin. - I treat visibility as audience and keep secrets out of every README.