← Learning Hub
Beginner

GitHub: Remote, Push, Pull and Clone

A remote is a copy of your repository on a server like GitHub. You push your commits up and pull other people's commits down.

A remote is a copy of your repository on a server like GitHub. Pushing uploads your commits; pulling downloads others'. This is how you back up your work, share it, and collaborate with people anywhere.

Put an existing project on GitHub

  • On github.com, click New repository, give it a name, and don't add a README (your project already has files).
  • Copy the address GitHub shows, then run:
Example
git remote add origin https://github.com/asha-verma/my-portfolio.git
git push -u origin main

origin is the usual name for the main remote. -u remembers the link, so next time just git push.

Daily work

Example
git pull                  # get the latest commits from GitHub (do this first!)
# ... edit, add, commit ...
git push                  # send your commits to GitHub

Copy someone's project

Example
git clone https://github.com/asha-verma/my-portfolio.git
cd my-portfolio

Signing in

GitHub doesn't accept your account password for Git. Use Git Credential Manager (installed with Git for Windows - a browser window opens to sign in), the GitHub CLI (gh auth login), or an SSH key.

Never commit passwords, API keys or .env files. Once pushed to a public repo, assume they are stolen - change them immediately.
Key points
  • git remote add origin URL connects to GitHub.
  • git push uploads; git pull downloads and merges.
  • git clone copies a remote repository.

📝 Test yourself

1. What does git push do?
2. What should you run before starting work on a shared repo?
3. Fill in the command that downloads a whole repository:
git https://github.com/user/repo.git