DevOps · Git

GitHub

GitHub hosts Git repositories online and adds collaboration: pull requests, issues, Actions and your public portfolio.

Beginner 5 min Lesson 4 of 30
Before you start:Git Fundamentals
0/30 in DevOps
On this page · 5 min · Beginner

Learning objectives#

  • Connect a local repo to GitHub
  • Push, pull and clone
  • Authenticate with SSH keys
  • Use issues and branch protection

Explanation#

A remote (usually named origin) is the GitHub copy of your repository. git push sends commits; git pull fetches and merges others’ commits.

Authenticate with SSH keys or the GitHub CLI (gh auth login) instead of passwords.

Issues track bugs and tasks; README.md is the front page of your project.

Branch protection rules can require pull requests, reviews and passing checks before merging to main.

Code example: Publish a project to GitHub#

ShellPublish a project to GitHub Illustrative
ssh-keygen -t ed25519 -C "asha@example.com"     # then add ~/.ssh/id_ed25519.pub in GitHub → Settings → SSH keys


git remote add origin git@github.com:asha/shop-api.git
git branch -M main
git push -u origin main


# Later, on another computer
git clone git@github.com:asha/shop-api.git
git pull          # get the latest commits
Expected output
To github.com:asha/shop-api.git
 * [new branch]      main -> main
branch 'main' set up to track 'origin/main'.

This example is illustrative. Copy or download it and run it in your own environment; the expected output is shown above.

Step-by-step explanation#

  1. An ed25519 SSH key authenticates you without passwords.
  2. git remote add connects the local repo to GitHub.
  3. push -u sets the upstream so later pushes are just git push.
  4. clone downloads the full repository elsewhere.

Real-world use case#

Students publish every project to GitHub with a good README; recruiters see real code and commit history.

Common mistakes#

Pushing directly to main in a team

Protect main and require pull requests.

Empty README

Explain what the project does, how to run it and include screenshots.

Best practices#

  • SSH or gh CLI authentication
  • Protect main with required reviews and checks
  • Write a helpful README
  • Enable secret scanning and Dependabot

Remember this#

origin = the GitHub copy.

push sends, pull receives, clone copies.

Protect main.

Practice exercise#

Your task: Show which remotes your repository has.

Show solution
Shell Illustrative
git remote -v

Mini quiz#

GitHub quizMultiple choice Question 1 of 1

What does git push -u origin main do the first time?

Score so far: 0/0

Want more? Practise all DevOps MCQs · DevOps interview questions

My notes#

Saved in this browser.

Progress is saved in this browser. Sign in to sync.