Learn

Connect your repo to GitHub

Git

Create a remote repo, wire it to your local, push and pull.

GitHub is the server where you publish your commits to back up your work and collaborate with others. This lesson connects your local repo to a GitHub repo, then shows you the push and pull operations you will use every day.

Create the repo on GitHub

Log in to github.com, click New repository. Give it a name, leave it empty (no README or .gitignore on the GitHub side), and create it.

GitHub then shows you the exact commands to run. We will walk through them below.

GitHub Docs - Create a repo

Add the remote

A "remote" is an alias for the URL of a remote repo. By convention, the main remote is called origin.

shell
git remote add origin https://github.com/your-name/your-repo.git

To verify the remote is configured correctly:

shell
git remote -v

You should see two lines: one for fetch and one for push, both pointing to your GitHub URL.

First push

The first time, you need to tell Git that the local main branch should push to origin/main:

shell
git push -u origin main

The -u (upstream) flag creates the link. After that, a plain git push is enough.

HTTPS or SSH?

Two ways to authenticate with GitHub:

  • HTTPS: you enter your username and a personal access token (not your password). Easy to set up, likely what you used above.
  • SSH: you generate a key pair, add the public key to your GitHub settings, and never type a password again. Ideal if you push frequently.

Pull: fetch remote changes

When someone else has pushed commits, or when you work from multiple machines, you pull the changes down:

shell
git pull

git pull is shorthand for git fetch (downloads remote commits) followed by git merge (integrates them into your current branch).

Clone an existing repo

If you are joining a project already hosted on GitHub, you do not need remote add. Just clone:

shell
git clone https://github.com/their-name/their-repo.git

This command creates a local folder, downloads the full history, and configures origin automatically.

git-scm.com - git remote

What comes next

With your repo on GitHub, you can create branches, push work, and open pull requests - the subject of the next lessons.

Concepts-ponts

Concept-pont · Git push, GitHub, et deploiement automatique

Pousser un commit sur GitHub n'est plus juste 'sauvegarder' : c'est aussi le declencheur du deploy continu et la source d'un graphe d'historique visualisable dans l'IDE.

Check off steps to unlock what comes next

Back to course