GitHub
Version control and code collaboration platform for software development.
Overview
GitHub is our primary platform for version control, code collaboration, and software development. It hosts our repositories, manages code reviews, tracks issues, and automates workflows through GitHub Actions.
What GitHub Provides
- Git repository hosting
- Code review and pull requests
- Issue tracking and project management
- CI/CD with GitHub Actions
- Documentation with GitHub Pages
- Team collaboration and permissions
- Code search and browsing
Getting Started
Account Access
- Check your email for the GitHub organization invitation
- Click Join [Organization Name]
- Sign in or create a GitHub account
- Accept the organization invitation
If you haven't received an invitation, contact TechOps to request access.
Sign In
- Go to github.com
- Click Sign in
- Enter your credentials or use Okta SSO
- Complete 2FA if enabled
First-Time Setup
Complete your profile:
- Add a profile photo
- Set your name and bio
- Add your email addresses
- Set your public visibility preferences
Configure SSH keys:
- Generate SSH key:
ssh-keygen -t ed25519 -C "your.email@company.com" - Add to GitHub: Settings → SSH and GPG keys → New SSH key
- Test connection:
ssh -T git@github.com
- Generate SSH key:
Configure Git locally:
bashgit config --global user.name "Your Name" git config --global user.email "your.email@company.com" git config --global init.defaultBranch mainEnable Two-Factor Authentication:
- Go to Settings → Password and authentication
- Click Enable two-factor authentication
- Choose authenticator app or SMS
- Save recovery codes securely
Basic Usage
Repositories
Clone a Repository:
# Using HTTPS
git clone https://github.com/organization/repo.git
# Using SSH (recommended)
git clone git@github.com:organization/repo.gitCreate a New Repository:
- Click + icon → New repository
- Enter repository name
- Choose public or private
- Add README, .gitignore, and license if desired
- Click Create repository
Fork a Repository:
- Navigate to the repository
- Click Fork button (top right)
- Choose your account or organization
- Clone your fork locally
Branches
Create a Branch:
# Create and switch to new branch
git checkout -b feature/new-feature
# Push to GitHub
git push -u origin feature/new-featureSwitch Branches:
git checkout main
git checkout feature/new-featureList Branches:
# Local branches
git branch
# All branches (local and remote)
git branch -aCommits
Make a Commit:
# Stage changes
git add .
# or stage specific files
git add file1.txt file2.txt
# Commit with message
git commit -m "Add new feature"
# Push to GitHub
git pushGood Commit Messages:
- Start with a verb: "Add", "Fix", "Update", "Remove"
- Be concise but descriptive
- Reference issue numbers: "Fix #123: Resolve login bug"
Pull Requests
Create a Pull Request:
- Push your branch to GitHub
- Navigate to the repository
- Click Pull requests → New pull request
- Choose base branch (usually
main) and compare branch (your feature branch) - Fill in title and description
- Add reviewers and labels
- Click Create pull request
Review a Pull Request:
- Go to Pull requests tab
- Click on the PR to review
- Review the Files changed tab
- Add comments on specific lines
- Submit review (Approve, Request changes, or Comment)
Merge a Pull Request:
- Ensure all checks pass
- Get required approvals
- Click Merge pull request
- Choose merge type:
- Create a merge commit - Keeps all commits
- Squash and merge - Combines into one commit
- Rebase and merge - Adds commits linearly
- Confirm merge
- Delete branch if done
Issues
Create an Issue:
- Go to Issues tab
- Click New issue
- Add a descriptive title
- Provide detailed description
- Add labels, assignees, and milestones
- Click Submit new issue
Reference Issues:
- In commits:
Fix #42: Resolve login error - In PRs:
Closes #42(will auto-close when merged) - In comments:
Related to #42
Features
GitHub Actions
Automate workflows with CI/CD:
- Create
.github/workflows/ci.ymlin your repository - Define triggers (push, pull request, schedule)
- Set up jobs and steps
- Use actions from the marketplace
- View workflow runs in the Actions tab
Example Workflow:
name: CI
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run tests
run: npm testCode Review
Review Best Practices:
- Review promptly (within 24 hours)
- Be constructive and respectful
- Focus on code, not the person
- Ask questions if unclear
- Suggest improvements
- Approve when ready
Projects
Organize work with GitHub Projects:
- Go to Projects tab
- Create a new project
- Choose view (Board, Table, Roadmap)
- Add issues and pull requests
- Organize with columns/fields
- Track progress
GitHub Pages
Host documentation or websites:
- Go to Settings → Pages
- Choose source (branch or GitHub Actions)
- Select folder (root or
/docs) - Save and wait for deployment
- Access at
https://username.github.io/repository
Common Issues
Permission Denied (SSH)
Problem: Permission denied (publickey) when pushing/pulling.
Solution:
- Check SSH key is added to GitHub:
ssh -T git@github.com - Verify SSH agent is running:
eval "$(ssh-agent -s)" - Add key to agent:
ssh-add ~/.ssh/id_ed25519 - Ensure key is added in GitHub settings
- Try HTTPS if SSH continues to fail
Authentication Failed (HTTPS)
Problem: Authentication fails when pushing via HTTPS.
Solution:
- GitHub removed password authentication
- Use a Personal Access Token (PAT) instead:
- Settings → Developer settings → Personal access tokens
- Generate new token (classic)
- Select appropriate scopes
- Use token as password when prompted
- Or switch to SSH authentication
Merge Conflicts
Problem: Can't merge due to conflicts.
Solution:
- Pull the latest changes:
git pull origin main - Git will mark conflicts in files
- Open conflicted files and resolve manually
- Remove conflict markers (
<<<<<<<,=======,>>>>>>>) - Stage resolved files:
git add . - Complete merge:
git commit - Push changes:
git push
Accidentally Committed to Wrong Branch
Problem: Made commits on main instead of feature branch.
Solution:
# Create new branch with current changes
git checkout -b feature/correct-branch
# Switch back to main
git checkout main
# Reset main to remote state
git reset --hard origin/main
# Switch to feature branch and push
git checkout feature/correct-branch
git push -u origin feature/correct-branchLarge File Error
Problem: "file exceeds GitHub's file size limit" error.
Solution:
- Remove large file from commit history:bash
git rm --cached large-file.zip git commit --amend -C HEAD - Add to
.gitignore - Use Git LFS for large files:bash
git lfs install git lfs track "*.zip" git add .gitattributes - Contact TechOps if you need LFS enabled
Best Practices
Repository Management
- Use meaningful names - Clear, descriptive repository names
- Write good READMEs - Explain purpose, setup, and usage
- Add a .gitignore - Exclude unnecessary files
- Include a LICENSE - Specify usage terms
- Protect main branch - Require reviews before merging
- Keep branches short-lived - Merge or delete regularly
Commit Practices
- Commit often - Small, logical commits
- Write good messages - Descriptive and consistent
- Don't commit secrets - Use environment variables
- Test before committing - Ensure code works
- Review your changes - Use
git diffbefore committing
Security
- Enable 2FA - Required for organization access
- Use SSH keys - More secure than passwords
- Rotate access tokens - Regularly update PATs
- Review third-party access - Check authorized applications
- Never commit secrets - No API keys, passwords, or tokens
- Use branch protection - Prevent force pushes to main
- Enable Dependabot - Automatic security updates
Collaboration
- Use descriptive PR titles - Clear and concise
- Fill out PR templates - Provide context
- Request specific reviewers - Get relevant expertise
- Respond to feedback - Address all comments
- Keep PRs focused - One feature or fix per PR
- Link related issues - Maintain traceability
How-To Guides
Set Up SSH Keys
Generate SSH key:
bashssh-keygen -t ed25519 -C "your.email@company.com" # Press Enter to accept default location # Enter a passphrase (recommended)Add key to SSH agent:
basheval "$(ssh-agent -s)" ssh-add ~/.ssh/id_ed25519Copy public key:
bash# macOS pbcopy < ~/.ssh/id_ed25519.pub # Linux cat ~/.ssh/id_ed25519.pubAdd to GitHub:
- Go to Settings → SSH and GPG keys
- Click New SSH key
- Paste key and save
Test connection:
bashssh -T git@github.com
Create a Pull Request
Create and switch to feature branch:
bashgit checkout -b feature/add-loginMake changes and commit:
bashgit add . git commit -m "Add login functionality"Push to GitHub:
bashgit push -u origin feature/add-loginCreate PR on GitHub:
- Click the notification link or go to repository
- Click Compare & pull request
- Fill in details
- Add reviewers
- Create pull request
Address review feedback:
bash# Make requested changes git add . git commit -m "Address review feedback" git pushMerge when approved:
- Click Merge pull request
- Confirm merge
- Delete branch
Resolve Merge Conflicts
Update your branch:
bashgit checkout main git pull origin main git checkout feature/your-branch git merge mainIdentify conflicts:
bashgit status # Shows conflicted filesOpen conflicted files and resolve:
<<<<<<< HEAD Your changes ======= Changes from main >>>>>>> mainRemove markers and keep desired code
Complete merge:
bashgit add resolved-file.txt git commit -m "Resolve merge conflicts" git push
Revert a Commit
Undo last commit (not pushed):
git reset --soft HEAD~1 # Keep changes staged
# or
git reset --hard HEAD~1 # Discard changesRevert a pushed commit:
# Creates new commit that undoes changes
git revert <commit-hash>
git pushRevert a merge:
git revert -m 1 <merge-commit-hash>
git pushQuick Reference
Common Git Commands
| Command | Description |
|---|---|
git clone <url> | Clone a repository |
git status | Check repository status |
git add <file> | Stage changes |
git commit -m "msg" | Commit changes |
git push | Push to remote |
git pull | Pull from remote |
git checkout <branch> | Switch branches |
git checkout -b <branch> | Create and switch to branch |
git merge <branch> | Merge branch |
git log | View commit history |
git diff | Show changes |
git stash | Temporarily save changes |
git stash pop | Restore stashed changes |
Keyboard Shortcuts (GitHub Web)
| Action | Shortcut |
|---|---|
| Search repository | / |
| Go to Code | g then c |
| Go to Issues | g then i |
| Go to Pull requests | g then p |
| Go to Actions | g then a |
| Create issue | c |
| Submit comment | Ctrl/Cmd + Enter |
GitHub CLI Commands
Install: cli.github.com
| Command | Description |
|---|---|
gh auth login | Authenticate with GitHub |
gh repo clone <repo> | Clone repository |
gh pr create | Create pull request |
gh pr list | List pull requests |
gh pr checkout <number> | Checkout PR locally |
gh issue create | Create an issue |
gh issue list | List issues |
Official Resources
- Documentation: docs.github.com
- GitHub Skills: skills.github.com
- Git Documentation: git-scm.com/doc
- Status Page: githubstatus.com
- Community: github.community
- GitHub CLI: cli.github.com
- GitHub Desktop: desktop.github.com
Support
TechOps Team:
- Slack: #techops-support
- For organization settings, permissions, or access issues
GitHub Support:
- Visit support.github.com
- Check githubstatus.com for service issues
- Browse docs.github.com for guides
Learning Resources:
- GitHub Skills - Interactive tutorials
- Pro Git Book - Free comprehensive guide
- Git Cheat Sheet
For detailed documentation and tutorials, visit docs.github.com