SovranCode
HomeCourses Git & GitHub GitHub Repository
This device
Course contentsGitHub Repository · 41 topics

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
Learn Git & GitHub40 complete · 1 planned

1. Git Fundamentals

Git IntroductionGit Version ControlGit vs GitHubGit InstallationGit Working TreeGit RepositoryGit CommitGit .gitignoreGit Project: Learning Journal

2. Git History

Git LogGit DiffGit ResetGit RevertGit StashGit Project: Messy Repository

3. Branches & History

Git BranchGit MergeGit Merge ConflictsGit RebaseGit Cherry-PickGit TagsGit Project: Feature Branch

4. Remotes and GitHub

Git RemoteGitHub AuthenticationGitHub RepositoryGitHub ForkGitHub IssuesGitHub PagesGit Project: Two Clone Sync

5. GitHub Collaboration

GitHub Pull RequestsGitHub Code ReviewGit Branching WorkflowGitHub Branch ProtectionGitHub CollaborationGitHub ContributingGit Project: Reviewed Pull Request

6. Automation and Professional Git

GitHub ActionsGit InternalsGit RecoveryGitHub SecurityGit Project: Team Repository CIProject
PREVIOUS LESSONGitHub Authentication
NEXT LESSONGitHub Fork
4. Remotes and GitHub 60 min

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.

What you will leave with

You will create a GitHub repository, choose visibility, write a README that tells a stranger how to clone and run the project, and push the first history without inventing a second root commit. Forks and pull requests come later.

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.

LOCAL

Git repository

Working tree, index, commits, and branch names such as main. git init already did this job.

GITHUB

Hosted repository

A namespace, visibility, browser page, and clone URL. GitHub stores Git objects; the page is not a substitute for git log.

Do not initialize twice

If the folder already has commits, GitHub must start empty. A README, license, or .gitignore checkbox on GitHub is a commit you do not have.

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 -vv

gh 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.

QUICK CHECK

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.

QUICK CHECK

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 origin

If 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.

QUICK CHECK

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 -v

A 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.

Local history is still intact

A rejected first push does not un-commit your work. Fix the remote, then push. Deleting the GitHub repository and creating an empty one is allowed for a disposable practice repo.

Guided practice: publish one disposable repo

  1. 01
    Commit locally first

    In a throwaway folder, write README.md, git add, and commit. Confirm git status is clean.

  2. 02
    Create empty on GitHub

    Use gh repo create without a README flag, or the website with initializers unchecked.

  3. 03
    Match the URL

    git remote -v must show HTTPS or SSH according to the credential you already proved.

  4. 04
    Push main

    Run git push -u origin main. Record git ls-remote origin and git branch -vv.

  5. 05
    Clone elsewhere

    Clone into /tmp and confirm the README and the same tip commit.

Independent lab: hosted copy matches local main

  1. Create a disposable local repository with a README that states clone instructions and that there is nothing to run.
  2. Create an empty public GitHub repository. Do not add a README, license, or gitignore on GitHub.
  3. Set origin if the CLI did not, then run git push -u origin main.
  4. Clone the GitHub URL into a second folder. Show that git log --oneline matches and README.md is present.
  5. Write four lines: visibility, why the GitHub repo was empty, the push command, and how you proved the hosted copy.
Definition of done

You can create an empty GitHub repository, push a named branch, show a matching clone, and explain why a GitHub README checkbox would have blocked that push.

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 main and prove it with git clone and git ls-remote origin.
  • I treat visibility as audience and keep secrets out of every README.

Related lessons

  • GitHub Authentication — The hosted URL is useless until a credential works.
  • Git Repository — The local Git repository is not the GitHub page.
  • Git Remote — origin is a Git remote that often points at GitHub.
  • GitHub Fork — A fork is another GitHub repository you clone as origin.
  • GitHub Issues — Issues live on the hosted GitHub repository, not in Git.
  • GitHub Pages — Pages is GitHub hosting on that same repository, not a Git command.
  • Git Project: Two Clone Sync — Two clones share this GitHub repository as origin, not as a second GitHub copy.
KNOWLEDGE CHECK

Check your GitHub repository model

Separate the local Git repository from the hosted page, create an empty remote when you already have commits, and prove the first push with a clone.

01How does a GitHub repository differ from the Git repository on your machine?
02You already have local commits. How should you create the GitHub repository?
03Does a private GitHub repository make a committed token safe?
04What does git push -u origin main do on a new empty GitHub repository?
05What job does README.md have on a new GitHub repository?
06Which URL should git clone use?
07The first push is rejected because the remote has a README commit. What should you do first?
PREVIOUS LESSONGitHub Authentication
NEXT LESSONGitHub Fork
ON THIS PAGEGitHub RepositoryThe GitHub page is not git initCreate empty when you already have commitsPublic and private are audience, not safetyWrite a README a stranger can usePoint origin at the new URLPush the first history on purposeProve it with a second cloneDiagnose a README that beat you to originGuided practice: publish one disposable repoIndependent lab: hosted copy matches local mainCommon repository mistakesLesson reviewKnowledge checkRelated lessons
Course contents