Git remotes: push & pull
This course covers working with Git remotes, using GitHub as the host. It starts with what a remote is and how push and pull move commits between your machine and a server. You set up SSH key authentication, connect an existing repository with git remote add, and send commits with git push and branch tracking. It then covers git clone, the difference between git fetch and git pull, and safe overwriting with --force-with-lease. The last lesson pushes a Rails app to GitHub and runs a full round trip.
What you'll learn
- ✓How remotes, push and pull relate, and how GitHub differs from Git
- ✓Setting up SSH key authentication with GitHub
- ✓Connecting and managing remotes with git remote
- ✓Pushing commits, tracking branches and overwriting safely with --force-with-lease
- ✓Starting from a remote with git clone
- ✓Inspecting incoming changes with git fetch before running git pull
Why remotes change everything
Every commit, branch, and undo trick from the last two courses happened entirely on your laptop. That is a complete, working version control system, and also, on its own, a single point of failure. Spill coffee on that laptop and every commit you ever made disappears with it. Worse: nobody else can…
Read the full lesson free →Curriculum
7 lessonsWhy remotes change everything
Explains what a remote is, the push and pull directions, and why GitHub is distinct from Git.
Authenticating with GitHub: SSH keys
Generates an ed25519 key pair, adds it to ssh-agent and GitHub, and tests the connection with ssh -T.
Connecting a local repo to GitHub: git remote
Connects a local repo to an empty GitHub repository with git remote add and covers renaming and removing remotes.
git push: sending commits to a remote
Covers the first push with -u, remote-tracking branches, rejected pushes and overwriting safely with --force-with-lease.
git clone: starting from a remote
Shows how git clone copies a full repository, configures origin and sets up main tracking in one command.
git fetch vs. git pull
Contrasts git fetch, which only updates origin/main, with git pull, which fetches and merges right away.
Putting it all together: push your Rails app to GitHub
Pushes a Rails app to GitHub, clones it into a second folder and pulls a change back.