Connecting to GitHub
Clone a Repository
# HTTPS
git clone https://github.com/username/repo.git
# SSH (after key setup)
git clone git@github.com:username/repo.gitSSH Key Setup (Recommended)
# Generate key pair
ssh-keygen -t ed25519 -C "your@email.com"
# Copy public key
cat ~/.ssh/id_ed25519.pubAdd the public key to GitHub: Settings → SSH Keys → New SSH Key.
Push & Pull Workflow
# Make changes locally
git add .
git commit -m "Add new feature"
# Push to remote
git push origin main
# Pull latest changes from remote
git pull origin main
# Fetch without merging (check first)
git fetch originBranching Workflow with GitHub
# Create feature branch
git switch -c feature/user-auth
# Work, commit...
git add .
git commit -m "Implement user authentication"
# Push branch to GitHub
git push -u origin feature/user-auth
# Create Pull Request on GitHub website
# After review and merge, clean up:
git switch main
git pull origin main
git branch -d feature/user-authPull Requests
Pull Requests (PRs) are how teams review and merge code:
- Push your branch to GitHub
- Click "New Pull Request" on GitHub
- Describe your changes
- Reviewers comment and approve
- Merge when approved
- Delete the branch
PR Best Practices
- Keep PRs small and focused
- Write clear descriptions
- Reference related issues
- Request specific reviewers
Forks
Fork = your own copy of someone else's repository:
- Click "Fork" on any public repo
- Clone YOUR fork locally
- Make changes and push to your fork
- Submit a PR to the original repo
This is how open-source contributions work.
Issues
Track bugs, features, and tasks:
- Create issues for work to be done
- Use labels (bug, enhancement, documentation)
- Reference issues in commits:
git commit -m "Fix login bug #42" - Close issues automatically:
Fixes #42in PR description
.gitignore
Exclude files from version control:
# .gitignore
node_modules/
.env
*.pyc
__pycache__/
.DS_Store
dist/
build/Summary
git clonedownloads a remote repositorygit pushsends commits to GitHub;git pullfetches and merges- SSH keys provide secure, passwordless authentication
- Pull Requests enable code review before merging
- Forks let you contribute to projects you don't own
.gitignoreexcludes files from tracking
Next Steps
Next, we'll cover Git workflows (Git Flow, GitHub Flow) and CI/CD with GitHub Actions.