GitHub Reference Guide
What is a Repository?
You can think of a repository as a folder that contains related items, such as files, images, videos, or even other folders. A repository usually groups together items that belong to the same “project” or thing you’re working on.
Often, repositories include a README file, a file with information about your project. README files are written in Markdown, which is an easy-to-read, easy-to-write language for formatting plain text.
About Branching
Branching lets you have different versions of a repository at one time.
By default, your repository has one branch named main that is considered to be the definitive branch. You can create additional branches off of main in your repository.
Branching is helpful when you want to add new features to a project without changing the main source of code. The work done on different branches will not show up on the main branch until you merge it, which we will cover later in this guide. You can use branches to experiment and make edits before committing them to main.
When you create a branch off the main branch, you’re making a copy, or snapshot, of main as it was at that point in time. If someone else made changes to the main branch while you were working on your branch, you could pull in those updates.
This diagram shows:
- The main branch
- A new branch called feature
-
The journey that feature takes through stages for “Commit changes,” “Submit pull request,” and “Discuss proposed changes” before it’s merged into main
📖 Learning Resources
🚀 Getting Started with GitHub
This section explains the core ideas behind accounts and repositories on GitHub. If you need terminal commands, see the Git guide in this course.
Creating Your GitHub Account
- Go to github.com
- Click “Sign up”
- Choose a username (this will be part of your profile URL)
- Use your college email address. (Normally your personal email ID is preferred but you can get Github Education pack for free if you use your College email address)
- Verify your account
Your First Repository
Method 1: Create on GitHub First
- Click the “+” icon → “New repository”
- Name your repository
- Add a description
- Choose Public or Private
- Initialize with README
- Click “Create repository”
Method 2: Push Existing Local Project
# In your project folder
git init
git add .
git commit -m "Initial commit"
git remote add origin https://github.com/username/repo-name.git
git push -u origin main
📁 Repository Management
Cloning Repositories
# Clone a repository
git clone https://github.com/username/repository-name.git
# Clone to specific folder
git clone https://github.com/username/repo.git my-folder
Repository Settings
- Description: Add a clear project description
- Topics: Add tags to help others find your project
- README: Always include a good README.md
- License: Choose an appropriate license
- Visibility: Public (everyone can see) vs Private (only you and collaborators)
🤝 Collaboration Features
Issues
Track bugs, feature requests, and tasks:
- Creating Issues
- Click “Issues” tab → “New issue”
- Use descriptive titles
- Add labels (bug, enhancement, question)
- Assign to team members
- Reference in commits:
git commit -m "Fix login bug, closes #15"
- Issue Templates
- Bug reports
- Feature requests
- Questions
Pull Requests (PRs)
Propose changes to a repository:
Creating a Pull Request
- Create a branch:
git checkout -b feature-name
- Make changes and commit
- Push branch:
git push -u origin feature-name
- Go to GitHub → “Compare & pull request”
- Add title and description
- Request reviewers
- Submit pull request
Pull Request Best Practices
- Clear, descriptive title
- Detailed description of changes
- Link related issues
- Keep changes focused and small
- Add screenshots for UI changes
Forking
Copy someone else’s repository to your account:
- Click “Fork” button on any repository
- Clone your fork:
git clone https://github.com/YOUR-USERNAME/REPO-NAME.git
- Add upstream remote:
git remote add upstream https://github.com/ORIGINAL-OWNER/REPO-NAME.git
- Keep your fork updated:
git fetch upstream git checkout main git merge upstream/main git push origin main
👥 Team Collaboration
Adding Collaborators
- Go to repository Settings
- Click “Manage access”
- Click “Invite a collaborator”
- Enter username or email
- Choose permission level
Branch Protection Rules
Protect your main branch:
- Settings → Branches
- Add rule for
main
- Enable:
- Require pull request reviews
- Require status checks
- Restrict pushes to main
Team Workflow
# 1. Get latest changes
git pull origin main
# 2. Create feature branch
git checkout -b feature/new-feature
# 3. Work and commit
git add .
git commit -m "Add new feature"
# 4. Push and create PR
git push -u origin feature/new-feature
# Then create PR on GitHub
# 5. After PR is merged, clean up
git checkout main
git pull origin main
git branch -d feature/new-feature
📊 GitHub Features for Projects
GitHub Pages
Host websites directly from your repository:
- Setup
- Go to Settings → Pages
- Choose source: Deploy from branch
- Select
main
branch - Your site:
https://username.github.io/repository-name
- Jekyll Sites (like this course!)
- Add
_config.yml
with theme - Use markdown files
- Automatic building and deployment
- Add
GitHub Actions (CI/CD)
Automate workflows:
- Run tests on every push
- Deploy applications
- Check code quality
- Send notifications
Basic workflow file (.github/workflows/test.yml
):
name: Run Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Run tests
run: npm test
Project Boards
Organize work with Kanban boards:
- Go to “Projects” tab
- Create new project
- Add columns (To Do, In Progress, Done)
- Add cards from issues and PRs
- Track progress visually
🔍 Exploring GitHub
Discovering Projects
- Trending: See popular repositories
- Topics: Browse by technology or subject
- Search: Use advanced search filters
- Awesome Lists: Curated lists of resources
Following and Starring
- Star repositories you find useful
- Follow developers whose work interests you
- Watch repositories for notifications
Your GitHub Profile
Make a great first impression:
- Profile README
- Create repository named your username
- Add README.md to showcase yourself
- Include your skills, projects, contact info
- Contribution Graph
- Shows your daily activity
- Green squares = commits
- Consistency matters more than intensity
📋 GitHub Commands Cheat Sheet
Action | Command/Location |
---|---|
Clone repository | git clone <url> |
Create issue | Issues tab → New issue |
Create PR | Compare & pull request |
Fork repository | Fork button |
Add collaborator | Settings → Manage access |
Enable Pages | Settings → Pages |
Create release | Releases → Create new release |
🎯 Practice Exercises
Exercise 1: Your First Repository
- Create a new repository on GitHub
- Clone it locally
- Add a README.md with your project description
- Commit and push changes
- Edit README on GitHub web interface
- Pull changes to local repository
Exercise 2: Collaboration Practice
- Fork a public repository
- Clone your fork
- Create a new branch
- Make a small improvement (fix typo, add comment)
- Push branch and create pull request
- Practice the full contribution workflow
Exercise 3: Issues and Project Management
- Create issues for features you want to add
- Use labels to categorize issues
- Create a project board
- Move issues through workflow stages
- Close issues with commit messages
🆘 Common GitHub Issues
“Permission denied (publickey)”
- Check SSH key setup
- Use HTTPS instead:
git remote set-url origin https://github.com/username/repo.git
“Repository not found”
- Check repository name and spelling
- Verify you have access to private repositories
- Ensure you’re logged in
“Merge conflicts in pull request”
- Pull latest changes from main branch
- Resolve conflicts locally
- Push resolved changes
“Can’t push to main branch”
- Branch protection rules are enabled
- Create a pull request instead
- Ask repository owner for permissions
💡 GitHub Best Practices
Repository Organization
- Clear, descriptive repository names
- Comprehensive README files
- Proper folder structure
- Include LICENSE file
- Add .gitignore for your language/framework
Commit Practices
- Atomic commits (one logical change per commit)
- Clear commit messages
- Reference issues in commits
- Use conventional commit format
Security
- Never commit passwords or API keys
- Use GitHub Secrets for sensitive data
- Enable two-factor authentication
- Review permissions regularly
Community Guidelines
- Be respectful in issues and PRs
- Provide constructive feedback
- Follow project contribution guidelines
- Help newcomers learn
Previous: Git Guide | Back to: Course Home |