FirstHack Learn
Log in Sign up free
Lessons in this course 0/6 All courses Git and GitHub for Students

First year

Progress0 / 6 lessons
  1. 1. What version control actually solves
  2. 2. init, add, commit: what a commit really is
  3. 3. Branches and merging
  4. 4. Remotes, push, pull and the rejected-push error
  5. 5. Merge conflicts, resolved step by step
  6. 6. Pull requests, .gitignore and a good README

Courses › Git and GitHub for Students

Remotes, push, pull and the rejected-push error

Connect your repository to GitHub and fix the error every student hits on day one.

12 min read · Lesson 4 of 6 · Pro

A remote is a nickname for a URL

Your repository lives on your laptop. A remote is a saved link to another copy of the same repository, usually on GitHub. The default nickname is origin.

Create an empty repository on GitHub first. Do not tick "Add a README" if you already have commits locally; it creates a commit on their side that yours does not know about, and that causes the first error below.

BASH
git remote add origin https://github.com/ravikumar/attendance-app.git
git remote -v
git push -u origin main

-u sets origin/main as the upstream for your local main. After that first push, plain git push and git pull know where to go.

The rest of this lesson is Pro

The free lessons of Git and GitHub for Students finish what they start — read those first if you have not. This one goes further, and it is part of the paid half.

A pass opens the paid lessons of every course, the mock test papers and the company-wise series. It ends on its own date; nothing renews by itself.

Get a pass — from ₹29 for 7 days

Already bought one? Log in.