Git and GitHub Notes
Introduction
What is Git?
- Git is a distributed version control system used to track changes in source code.
- It allows multiple developers to collaborate on a project efficiently.
- Supports branching, merging, and version history.
What is GitHub?
- GitHub is a web-based platform that hosts Git repositories.
- It provides tools for collaboration, such as:
- Pull Requests
- Issues
- Project boards
- GitHub Actions (CI/CD)
Git Workflow Basics
Initial Setup
Starting a Repository
Staging and Committing Changes
git status # View current changes
git add <file> # Stage a file
git add . # Stage all changes
git commit -m "message" # Commit staged changes
Checking History
Branching and Merging
Working with Branches
git branch # List branches
git branch <name> # Create a branch
git checkout <name> # Switch to a branch
git checkout -b <name> # Create and switch
Merging Branches
Remote Repositories
Adding and Pushing to Remote
Pulling and Fetching
GitHub Essentials
Cloning a Repo
Creating a Pull Request (PR)
- Fork the repository
- Clone your fork
- Create a new branch
- Commit and push changes
- Open a PR on GitHub
GitHub Features
- Issues: Report bugs, suggest features
- Actions: Automate workflows
- Wiki: Share documentation
- Projects: Organize tasks with kanban boards
.gitignore
Used to exclude files/folders from version control:
Git and GitHub Notes
Introduction
What is Git?
- Git is a distributed version control system used to track changes in source code.
- It allows multiple developers to collaborate on a project efficiently.
- Supports branching, merging, and version history.
What is GitHub?
- GitHub is a web-based platform that hosts Git repositories.
- It provides tools for collaboration, such as:
- Pull Requests
- Issues
- Project boards
- GitHub Actions (CI/CD)
Git Workflow Basics
Initial Setup
Starting a Repository
Staging and Committing Changes
git status # View current changes
git add <file> # Stage a file
git add . # Stage all changes
git commit -m "message" # Commit staged changes
Checking History
Branching and Merging
Working with Branches
git branch # List branches
git branch <name> # Create a branch
git checkout <name> # Switch to a branch
git checkout -b <name> # Create and switch
Merging Branches
Remote Repositories
Adding and Pushing to Remote
Pulling and Fetching
GitHub Essentials
Cloning a Repo
Creating a Pull Request (PR)
- Fork the repository
- Clone your fork
- Create a new branch
- Commit and push changes
- Open a PR on GitHub
GitHub Features
- Issues: Report bugs, suggest features
- Actions: Automate workflows
- Wiki: Share documentation
- Projects: Organize tasks with kanban boards
.gitignore
Used to exclude files/folders from version control: ```plaintext