Welcome to the Git and GitHub section! This guide will help you understand version control systems that are essential for any developer.
Git is a distributed version control system that helps you track changes in your code and collaborate with others. It lets you save snapshots of your project and return to them when needed.
GitHub is a web-based platform built around Git that adds collaboration features, issue tracking, project management, and more. It's where many open-source projects live and where developers showcase their work.
-
Setting Up
- Installing Git
- Configuring your identity
- Basic terminal/command line navigation
-
Core Concepts
- Repositories
- Commits
- Branches
- The staging area (index)
- Working directory
-
Essential Commands
git init- Create a new repositorygit clone- Copy a repositorygit add- Stage changesgit commit- Record changesgit status- Check statusgit log- View historygit diff- See changesgit checkout- Switch branches
-
Branching and Merging
- Creating branches
- Switching between branches
- Merging branches
- Resolving merge conflicts
-
Account Setup
- Creating an account
- Setting up SSH keys
- Configuring profile
-
Remote Repositories
git remote- Managing remotesgit push- Uploading changesgit pull- Downloading changesgit fetch- Getting updates
-
Collaboration
- Forking repositories
- Creating pull requests
- Code reviews
- Issues and discussions
-
GitHub Features
- GitHub Pages
- GitHub Actions (CI/CD)
- Project boards
- GitHub Discussions
-
History Manipulation
- Interactive rebase
- Cherry-picking
- Reset vs Revert
- Reflog
-
Git Workflows
- Feature branch workflow
- Gitflow
- Trunk-based development
- Fork and pull model
-
Git Internals
- Objects and references
- Git's data model
- Hooks
- Custom commands
# Start a new feature
git checkout -b new-feature main
# Make changes
# ... edit files ...
# Stage and commit
git add .
git commit -m "Add new feature"
# Push to remote
git push -u origin new-feature
# Update your local copy
git checkout main
git pull
# Create feature branch
git checkout -b new-feature
# Make changes and commit
# ... edit files ...
git add .
git commit -m "Implement feature"
# Stay up to date with main
git fetch origin
git rebase origin/main
# Push to remote
git push -u origin new-feature
# Create pull request on GitHub
- "Pro Git" by Scott Chacon and Ben Straub (free online)
- "Git for Humans" by David Demaree
- Commit Often: Make small, focused commits rather than large changes
- Write Good Messages: Clear commit messages help everyone understand changes
- Pull Before Push: Always update your local copy before pushing
- Use Branches: Keep your work organized with feature branches
- Learn From Mistakes: Git lets you recover from almost any mistake
Remember that Git has a learning curve, but it becomes second nature with practice. Don't be afraid to experiment - you can always use git reflog to find your way back if you get lost.
Explore the subdirectories for more detailed resources and examples on Git and GitHub usage.