This guide will help you understand Git and GitHub workflows for contributing to open source projects during Hacktoberfest 2025.
- Prerequisites
- Basic Git Concepts
- Setting Up Your Environment
- Complete Contribution Workflow
- Common Commands Reference
- Troubleshooting Common Issues
- Best Practices
- GitHub account
- Git installed on your computer
- Basic command line knowledge
- Text editor (VS Code, Sublime Text, etc.)
Git is a version control system that tracks changes in files and coordinates work among multiple people.
- Repository (Repo): A project folder that contains all files and their version history
- Fork: A personal copy of someone else's repository
- Clone: Downloading a repository to your local machine
- Branch: A parallel version of the main codebase
- Commit: A saved snapshot of changes
- Pull Request (PR): A request to merge your changes into the main repository
- Merge: Combining changes from different branches
# Windows (using Git for Windows)
# Download from: https://git-scm.com/download/win
# macOS (using Homebrew)
brew install git
# Linux (Ubuntu/Debian)
sudo apt-get install gitgit config --global user.name "Your Name"
git config --global user.email "your.email@example.com"ssh-keygen -t ed25519 -C "your.email@example.com"
# Add the public key to your GitHub account- Go to the repository on GitHub
- Click the "Fork" button in the top-right corner
- This creates a copy in your GitHub account
git clone https://github.com/YOUR_USERNAME/REPO_NAME.git
cd REPO_NAMEgit remote add upstream https://github.com/ORIGINAL_OWNER/REPO_NAME.gitgit checkout -b feature/your-feature-name
# or
git switch -c feature/your-feature-name- Edit files using your preferred text editor
- Test your changes locally
- Follow the project's coding standards
# Check what files have changed
git status
# Add specific files
git add filename.txt
# Add all changes
git add .
# Add changes interactively
git add -pgit commit -m "Add: brief description of your changes"
# For more detailed commits
git commit -m "Add: feature description
- Detailed explanation of changes
- Why this change was made
- Any additional context"git push origin feature/your-feature-name- Go to your fork on GitHub
- Click "Compare & pull request"
- Fill out the PR description
- Submit the pull request
# Fetch changes from upstream
git fetch upstream
# Switch to main branch
git checkout main
# Merge upstream changes
git merge upstream/main
# Push updates to your fork
git push origin main# Check status
git status
# View commit history
git log --oneline
# View differences
git diff
# View staged changes
git diff --staged
# Undo changes
git checkout -- filename.txt
# Unstage files
git reset HEAD filename.txt# List branches
git branch
# Switch branches
git checkout branch-name
git switch branch-name
# Delete branch
git branch -d branch-name
# Delete remote branch
git push origin --delete branch-name# List remotes
git remote -v
# Add remote
git remote add name url
# Remove remote
git remote remove name
# Fetch from remote
git fetch remote-name# Interactive rebase
git rebase -i HEAD~3
# Cherry-pick commit
git cherry-pick commit-hash
# Stash changes
git stash
git stash pop
# Amend last commit
git commit --amendSolution: Set up SSH keys or use HTTPS instead
git clone https://github.com/USERNAME/REPO.gitSolution: Pull latest changes
git pull upstream mainSolution: Resolve conflicts manually
- Open conflicted files
- Choose which changes to keep
- Remove conflict markers (
<<<<<<<,=======,>>>>>>>) - Stage resolved files:
git add filename.txt - Complete merge:
git commit
Solution: Amend the commit
git commit --amend -m "Correct message"Solution: Create new branch and reset
git checkout -b feature-branch
git checkout main
git reset --hard HEAD~1
git checkout feature-branch- Use imperative mood: "Add feature" not "Added feature"
- Keep first line under 50 characters
- Use body for detailed explanations
- Reference issues: "Fix #123"
- Use descriptive names:
feature/user-authentication - Include issue numbers:
fix/issue-456 - Use prefixes:
feature/,fix/,docs/,test/
- Test your changes locally
- Follow project coding standards
- Write clear, readable code
- Add comments for complex logic
- Write clear PR descriptions
- Reference related issues
- Request reviews from maintainers
- Respond to feedback promptly
- Keep PRs focused and small
- Keep your fork updated
- Delete merged branches
- Clean up old branches
- Sync with upstream regularly
- Git Official Documentation
- GitHub Docs
- Atlassian Git Tutorials
- GitHub Learning Lab
- First Contributions
# Daily workflow
git status # Check status
git add . # Stage changes
git commit -m "message" # Commit changes
git push origin branch-name # Push to GitHub
# Sync with upstream
git fetch upstream # Get latest changes
git merge upstream/main # Merge changes
git push origin main # Update your fork
# Create new feature
git checkout -b feature/name # Create branch
# ... make changes ...
git add . # Stage changes
git commit -m "message" # Commit changes
git push origin feature/name # Push branchHappy Contributing! 🎉
Remember: Every expert was once a beginner. Don't be afraid to ask questions and learn from the community!