Advanced GitHub Guide for Regular Users
Table of Contents
1. Introduction
2. Effective Collaboration
○ Branching Strategies
○ Commit Message Best Practices
○ Pull Requests and Code Reviews
3. Exploring Advanced GitHub Features
○ GitHub Issues
○ GitHub Projects and Boards
○ GitHub Actions
○ GitHub Pages
4. Deepening Your Git Knowledge
○ Merge Conflicts
○ Rebasing vs. Merging
○ Undoing Changes Safely
5. GitHub Security Best Practices
○ Account Security
○ Managing Secrets
○ Repository Permissions
6. Additional Tips and Resources
1. Introduction
This guide aims to elevate your GitHub workflow beyond pushing code and cloning repositories.
Whether you're collaborating on team projects, managing your own portfolio, or contributing to
open-source, mastering advanced Git and GitHub features is key to becoming a proficient
developer.
2. Effective Collaboration
Branching Strategies
● Main Branch Protection: Keep main or master stable. Always create a new branch
for features or fixes:git checkout -b feature/your-feature-name
● Naming Conventions: Use clear prefixes:
○ feature/: new features
○ bugfix/: bug fixes
○ hotfix/: urgent fixes
○ chore/: maintenance tasks
Commit Message Best Practices
● Structure:
○ Title (50 characters max)
○ Optional detailed body (wrapped at 72 chars)
● Types:
○ feat: – new feature
○ fix: – bug fix
○ docs: – documentation
○ refactor: – code improvement
○ test: – adding or updating tests
○ chore: – routine task
● Example:feat: implement user login API - Created login endpoint with JWT
authentication - Added input validation and error handling
Pull Requests and Code Reviews
● PR Workflow:
○ Push your feature branch.
○ Open a pull request (PR) against the main branch.
○ Request reviews.
○ Address feedback.
○ Merge once approved.
● Tips:
○ Link related issues (Fixes #123).
○ Use GitHub suggestions in code reviews.
○ Keep PRs small and focused.
3. Exploring Advanced GitHub Features
GitHub Issues
● Track work with Issues:
○ Title + description
○ Assign members
○ Set labels, milestones, due dates
● Templates for consistency:
○ .github/ISSUE_TEMPLATE/bug_report.md
GitHub Projects and Boards
● Kanban or custom workflows:
○ Columns: To Do, In Progress, Review, Done
○ Link issues and PRs
● Automation:
○ Auto-move cards on PR merge/close
GitHub Actions
● Automate tasks (CI/CD):
○ Testing, building, deploying
● Example: Node CIname: Node CI on: [push, pull_request] jobs: build: runs-on:
ubuntu-latest steps: - uses: actions/checkout@v3 - uses: actions/setup-
node@v3 with: node-version: '16' - run: npm install - run: npm test
GitHub Pages
● Free static hosting from GitHub repo
● Good for portfolios, blogs, docs
● Setup:
○ Push HTML/Markdown to main or gh-pages
○ Settings → Pages → Select branch
4. Deepening Your Git Knowledge
Merge Conflicts
● When they happen:
1. Conflicting changes in the same file lines
● How to resolve:
1. Edit conflicting sections (<<<<<<<, =======, >>>>>>>)
2. Mark as resolved:git add file git commit
Rebasing vs. Merging
● Merge: Combines histories. Keeps full log.git merge branch-name
● Rebase: Rewrites commits on top of base.git rebase main
● Use rebase for linear history in solo branches.
● Use merge for collaborative PRs to preserve history.
Undoing Changes Safely
● Reset (local, unsafe):git reset --hard HEAD~1
● Revert (safe):git revert <commit-hash>
● Stashing (temporary changes):git stash git stash pop
5. GitHub Security Best Practices
Account Security
● Enable 2FA for account protection
● Use SSH keys:Add public key in GitHub → Settings → SSH and GPG Keysssh-
keygen -t ed25519 -C "your_email@example.com"
Managing Secrets
● Avoid pushing secrets (API keys, passwords)
● Add to .gitignore:.env config/*.secret.js
● Use environment variables in Actions:env: API_KEY: ${{ secrets.API_KEY }}
Repository Permissions
● Use teams and roles:
○ Read, Triage, Write, Maintain, Admin
● Limit write access to main
● Enable branch protection rules
6. Additional Tips and Resources
● Practice: Use a test repo to try advanced commands
● Read:
○ Pro Git Book
○ GitHub Docs
● Watch: GitHub Universe talks, YouTube tutorials
● Contribute: Try open-source beginner issues
Happy coding! Mastering these practices will make you a stronger, more confident Git and
GitHub user. 🚀