Hands-on exercises and notes for beginners to learn GitHub.
This repository contains materials, exercises, and guides for learning Git and GitHub from scratch.
Duration: 1 Hour
Target Audience: Beginners with zero prior experience in Git or GitHub
Version control is a system that helps you:
- Track changes in your code.
- Revert to previous versions if something breaks.
- Collaborate easily with others on the same project.
Think of it like a time machine for your code
| Feature | Git | GitHub |
|---|---|---|
| Type | Tool (installed locally) | Cloud platform (web-based) |
| Purpose | Track and manage code versions on your computer | Host and share Git repositories online |
| Access | Command-line | Website / Web App |
| Internet Required | No (works offline) | Yes |
| Example | git commit, git log, git checkout |
Create repo, fork, pull request, add collaborators |
| Analogy | Saving files in folders locally | Uploading files to Google Drive to share |
In short:
Git = Version control tool
GitHub = Collaboration and hosting platform for Git repositories
The Git workflow follows a simple process that helps developers manage versions efficiently.
Each step represents a stage in your project’s life cycle, from local changes to sharing online.
Where you edit your files (create, modify, delete code).
Temporary area where you mark files that you want to commit.
Where committed changes are permanently saved on your system.
Online version of your repository to collaborate and share with others.
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
git init ##Initialize Repository
git add filename.py ##Track Files
git add .
git commit -m "Your message" ## Commit Changes
git status ##Check Status
git log ##View History
git diff ##See Differences
##Restore / Rollback
git diff --staged
git restore filename.py
git checkout <commitID> -- filename.pygit remote add origin https://github.com/username/repo.git
git push -u origin maingit clone https://github.com/username/repo.git
git pull origin mainBranching allows working on new features, bug fixes, or experiments without affecting the main code.
# Create a branch
git branch <branch-name>
# Switch to a branch
git switch <branch-name>
# Stage changes
git add <file>
# Commit changes
git commit -m "Your commit message"
# Merge a branch into main
git switch main
git merge <branch-name>
# Delete a branch
git branch -d <branch-name> # Local
git push origin --delete <branch-name> # RemoteUse clear, descriptive names for branches to make collaboration easier:
feature/login-pagebugfix/navbar-issuedocs/readme-updatehotfix/crash-fix
- Create a branch
- Add a file
- Commit changes
- Merge branch into main
- Delete branch locally & remotely
- Occur when multiple changes overlap
- Resolve manually in a code editor or directly in the GitHub UI
Pull Requests (PRs) are how you propose changes from your branch to the main branch. They are essential for collaboration and code review.
-
Forking vs Branching Workflow
- Forking: copy someone else’s repo to your account (common in open-source)
- Branching: create a branch in the same repo (common in team projects)
-
Create a Pull Request
- Push your branch to GitHub:
git push origin <branch-name>
- Go to your repository on GitHub → Click "Compare & pull request"
- Add a title and description for your PR
- Push your branch to GitHub:
-
Assign Reviewers & Add Labels
- Assign a team member to review your changes
- Add labels like
bug,feature,documentationfor clarity
-
Code Review & Approval
- Reviewer checks the changes
- Add comments if improvements are needed
- Approve PR once ready
-
Merge Pull Request
- Click "Merge pull request" on GitHub
- Optionally delete the branch after merging
-
Link PRs to Issues
- Use keywords like
fixes #3in PR description to automatically close the linked issue
- Use keywords like
-
Resolve Conflicts
- If there are conflicts, GitHub UI shows them
- Edit directly in GitHub or locally to resolve
-
Bonus
- Use GitHub Issues to track tasks
- Use Project Boards for organizing teamwork
-
Format:
feat: add login page fix: navbar alignment issue docs: update README
-
Keep commit messages short, meaningful, and consistent
-
Make small, focused commits
-
Using .gitignore
-
Avoid committing unnecessary files like IDE configs or temporary files
-
Example:
*.log node_modules/ .env- Quick hack: generate templates at gitignore.io
-
-
Avoid Large Binaries
- Don’t commit large files; use Git LFS if needed
-
Stash Temporary Work
git stash # Save changes temporarily git stash pop # Retrieve stashed changes
-
Undo Safely
-
Safe undo: git revert (creates a new commit)
-
Advanced: git reset (can rewrite history; use with caution)
-
-
Protect Main Branch
-
Enable branch protection rules on GitHub
-
Require PR reviews before merge
-
-
Conceptual Notes
-
Rebase vs Merge (just concept for now)
-
Intro to CI integration (testing before merge)
-
-
README Best Practices
-
Include badges (build, license, coverage)
-
Project description & setup steps
-
Screenshots of the project
-
Contributors / team members
-
Create a repo
- Add a file
- Create a branch
- Modify the file
- Push changes
- Create a PR
- Assign a friend as reviewer
- Merge the PR
- Provide Cheat-Sheet
Follow Jenefer Rexee on LinkedIn
Follow Kiruthiga Ravi on LinekedIn