Version Control
Version control systems help teams manage changes to code over time. We use GitHub as our primary platform for version control and collaboration.
GitHub
GitHub is a web-based platform that provides hosting for software development and version control using Git.
GitHub
Key Features
- Repository hosting and management
- Issue tracking and project management
- Pull requests for code review
- Actions for CI/CD automation
- Collaboration tools for teams
Git Basics
Understanding the fundamental Git commands is essential for effective version control.
Initializing a Repository
git init
Creates a new Git repository in the current directory.
Cloning a Repository
git clone https://github.com/username/repository.git
Creates a copy of a remote repository on your local machine.
Checking Status
git status
Shows the current state of your working directory and staging area.
Adding Changes
git add filename
git add .
Adds file changes to the staging area.
Committing Changes
git commit -m “Commit message”
Records changes to the repository with a descriptive message.
Pushing Changes
git push origin branch-name
Uploads local repository content to a remote repository.
Branching Strategy
A good branching strategy helps teams collaborate effectively and maintain code quality.
Creating a Branch
git checkout -b feature/new-feature
Creates and switches to a new branch for developing a feature.
Switching Branches
git checkout branch-name
Switches to an existing branch.
Merging Branches
git checkout main
git merge feature/new-feature
Incorporates changes from one branch into another.
Pull Requests
Pull requests are a way to propose changes to a codebase and facilitate code review.
Creating a Pull Request
- Push your branch to GitHub
- Navigate to the repository on GitHub
- Click on “Pull requests” tab
- Click “New pull request”
- Select your branch as the compare branch
- Fill in the title and description
- Click “Create pull request”
Reviewing a Pull Request
- Open the pull request
- Review the changes in the “Files changed” tab
- Add comments on specific lines if needed
- Approve or request changes
- Merge the pull request when ready