PTENES
MODULE 6.2

🐙 GitHub and repositories

Bring your local repository to the cloud: create repos, configure SSH, use the gh CLI in the terminal, open PRs, and write an impressive README. GitHub is your professional showcase.

6
Topics
~45
Minutes
⚡
Intermediate
🛠️
Practical
1

🏗️ Create a repository

Web vs. gh CLI — two paths to the same destination

1

Via gh CLI (recommended)

$ gh repo create meu-projeto --public --clone
$ gh repo create meu-projeto --private --add-readme
$ gh repo create           # modo interativo (pergunta tudo)
2

Connect an existing local repo to GitHub

$ git remote add origin git@github.com:user/repo.git
$ git push -u origin main
$ git remote -v    # confirma remote configurado

✓ Public repo: ideal for your portfolio

  • ✓Indexed by Google and GitHub search
  • ✓Free and unlimited GitHub Pages
  • ✓External contributors can help

🔒 Private Repo: For Internal Projects

  • →Code not publicly exposed
  • →Collaborators need an invitation
  • →GitHub Pages requires a paid plan (except for organizations)
🌐
Public
Portfolio and open source
🔒
Private
Personal/commercial projects
🍴
Fork
Copy of another project
📥
Clone
Download to your computer
2

📡 Remote and push

Sync local with GitHub — the loop you’ll repeat every day

LOCAL your computer commits git push git pull / fetch 🐙 GITHUB origin/main remote history secure backup collab A collab B you team

Push sends, pull receives — GitHub is the central sync point.

REMOTE AND SYNC
$ git push -u origin main    # primeiro push + configura tracking
$ git push                   # pushes seguintes (tracking já configurado)
$ git pull                   # baixa + mescla mudanças remotas
$ git fetch                  # baixa SEM mesclar (mais seguro)
$ git remote -v              # lista remotes configurados
$ git remote set-url origin URL  # muda a URL do remote

💡 push --force-with-lease: the safe way

Never use git push --force on a shared branch — it destroys other people's work. Use --force-with-lease: only forces it if no one has pushed before you.

⬆️
git push
Sends local commits
⬇️
git pull
Downloads + merges
🔄
git fetch
Downloads without merging
📡
origin
Default remote name
3

🔑 SSH vs HTTPS

Authenticate once, work forever without entering a password

SSH — recommended for daily use

  • ✓Key pair: the public key stays on GitHub, the private key stays on your computer
  • ✓No need to type your password with every push/pull
  • ✓URL: git@github.com:user/repo.git
  • ✓Works perfectly with Claude Code in automation

HTTPS — simpler to configure

  • →Personal access token (PAT) instead of a password
  • →URL: https://github.com/user/repo.git
  • →Credential helper caches the token
  • →Easier to use behind corporate firewalls
CONFIGURE SSH — STEP BY STEP
# 1. Gerar chave
$ ssh-keygen -t ed25519 -C "seu@email.com"
# pressione Enter para aceitar o caminho padrão (~/.ssh/id_ed25519)

# 2. Copiar a chave pública
$ cat ~/.ssh/id_ed25519.pub
# copie todo o output e cole em GitHub → Settings → SSH keys → New SSH key

# 3. Testar conexão
$ ssh -T git@github.com
Hi usuario! You've successfully authenticated, but GitHub does not provide shell access.

# 4. Mudar remote existente de HTTPS para SSH
$ git remote set-url origin git@github.com:user/repo.git
🔐
ed25519
Recommended algorithm
🗝️
~/.ssh/
Keys folder
📋
PAT
Personal HTTPS token
💾
Credential helper
Caches credentials
4

⚡ gh CLI

GitHub in the terminal—create repos, PRs, releases, and much more without opening a browser

🤖 Claude Code Uses gh Extensively

When you ask Claude Code to create PRs, check CI/CD, make releases, or open issues, it uses gh behind the scenes. Understanding the commands lets you audit what was done and customize the behavior.

gh CLI — ESSENTIAL COMMANDS
# Autenticação
$ gh auth login                          # autentica com GitHub
$ gh auth status                         # verifica autenticação

# Repositórios
$ gh repo create nome --public --clone    # cria e clona
$ gh repo view                           # detalhes do repo atual
$ gh repo clone user/repo                # clona repo

# Pull Requests
$ gh pr create --title "feat: X" --body "Descrição"
$ gh pr list                             # lista PRs abertos
$ gh pr merge --squash --delete-branch   # merge com squash

# Issues
$ gh issue create --title "Bug: X" --label bug
$ gh issue list --label "good first issue"

# Releases
$ gh release create v1.0.0 --generate-notes
$ gh release list

# GitHub Actions / CI
$ gh run list                            # lista execuções recentes
$ gh run watch                           # monitora execução em tempo real

⚡ Install gh CLI

# macOS: brew install gh

# Ubuntu/Debian: sudo apt install gh

# Windows: winget install GitHub.cli

🔑
gh auth login
Once, forever
📁
gh repo create
New repo in seconds
🔀
gh pr create
PR without opening a browser
📊
gh run watch
Real-time CI
5

🔀 Pull requests

Structured collaboration — review before merge

1

Create a branch + commit + push

git checkout -b feature/nova-funcao
git add . && git commit -m "feat: adiciona nova funcão"
git push -u origin feature/nova-funcao
2

Open the PR via the gh CLI

gh pr create \
  --title "feat: adiciona nova funcão" \
  --body "## O que faz\n- Item 1\n\n## Como testar\n- Passo 1" \
  --base main
3

Review, approve, and merge

gh pr review --approve       # aprovar
gh pr merge --squash --delete-branch  # merge com squash
gh pr checks                  # verificar CI
📝
Draft PR
Visible WIP for the team
✅
Approve
Green light to merge
🗜️
Squash merge
1 clean commit on main
🤖
PR template
.github/pull_request_template
6

📖 Effective README

The project’s first impression — the difference between being ignored and starred

README.md — RECOMMENDED STRUCTURE
# 🚀 Nome do Projeto

> Uma linha descrevendo o que faz e para quem.

![Status](https://img.shields.io/badge/status-ativo-success)
![License](https://img.shields.io/badge/license-MIT-blue)

## ✨ O que faz
Lista rápida com os principais benefícios.

## 🛠️ Tecnologias
- Lista de tecnologias usadas

## 🚀 Como usar
```bash
git clone ...
npm install
npm start
```

## 📸 Preview
[screenshot ou GIF aqui]

## 📄 Licença
MIT — veja LICENSE para detalhes.

✓ README that works

  • ✓First sentence: explains the project in 10 seconds
  • ✓Screenshot or GIF above the fold
  • ✓Installation in fewer than 3 commands
  • ✓Visual status, license, and version badges

✗ README that turns people away

  • ✗Empty README or "TODO"
  • ✗No installation instructions
  • ✗Walls of unformatted text
  • ✗Not updated after project changes

🤖 Claude Code generates a README

Ask: "Analyze this project and generate a complete README.md with badges, installation, usage, and real examples." Claude reads the code and generates accurate documentation in seconds.

🏷️
Badges
shields.io
📸
Screenshot
Worth more than a thousand words
⚖️
LICENSE
MIT for open projects
🤝
CONTRIBUTING
How to collaborate

🎯 Module summary

What you learned

  • ✓Create a repository via gh CLI or the web
  • ✓Configure the remote and push/pull
  • ✓SSH with ed25519 — passwordless authentication
  • ✓gh CLI: repos, PRs, issues, releases
  • ✓Complete Pull Request flow
  • ✓Well-structured README that impresses

Next module

With the repository on GitHub, the next step is to publish it for free with GitHub Pages—and make your project accessible to the whole world in minutes.

Module 6.3 — GitHub Pages→