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 repoAdd the remote
A "remote" is an alias for the URL of a remote repo. By convention, the main remote is called origin.
To verify the remote is configured correctly:
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:
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:
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:
This command creates a local folder, downloads the full history, and configures origin automatically.
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
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.
