This repository contains a step-by-step implementation of various Git workflows and features. The project includes a basic calculator application with arithmetic operations, a geometry calculator for calculating areas of different shapes, and demonstrates Git LFS for handling large files. This assignment showcases best practices for branching, merging, collaboration, and version control.
- โจ Git installed on your local machine
- ๐ GitHub account
- ๐ Basic knowledge of Python
- ๐ฆ Git LFS installed (for Question 2)
- ๐ป Access to terminal or command prompt
git_assignment_HeroVired/
โโโ .git/ # Git repository data
โโโ .gitattributes # Git LFS configuration file
โโโ calculator.py # Basic calculator implementation
โโโ geometry_calculator.py # Geometry calculator implementation
โโโ README.md # Project documentation
- ๐ข
main(default) - ๐ ๏ธ
dev - ๐ด
feature/circle-area - ๐
feature/rectangle-area - ๐งฎ
feature/sqrt - ๐
geometry-calculator - ๐ฆ
lfs
-
๐ Login to GitHub
- Navigate to GitHub.com and sign in
- Click the "+" in top-right corner โ "New repository"
-
โ๏ธ Configure Repository
- Name:
git_assignment_HeroVired - Visibility: Private
- โ Initialize with README
- Name:
-
๐ฅ Clone to Local Machine
git clone https://github.com/yourusername/git_assignment_HeroVired.git cd git_assignment_HeroVired -
๐ฑ Create Development Branch
git checkout -b dev -
๐ป Add Calculator Code I've created
calculator.py:import math class Calculator: def add(self, a, b): return a + b def subtract(self, a, b): return a - b def multiply(self, a, b): return a * b def divide(self, a, b): return a / b if __name__ == "__main__": calculator = Calculator() num1 = 16 num2 = 4 print(f"{num1} + {num2} = {calculator.add(num1, num2)}") print(f"{num1} - {num2} = {calculator.subtract(num1, num2)}") print(f"{num1} * {num2} = {calculator.multiply(num1, num2)}") print(f"{num1} / {num2} = {calculator.divide(num1, num2)}")
-
๐ค Commit & Push Changes
git add . git commit -m "Added initial calculator code" git push origin dev -
๐ Merge & Tag Release v1.0
git checkout main git merge dev git push origin main git tag v1.0 git push origin v1.0
- I've gone to repository โ Settings โ Collaborators โ๏ธ
- I've clicked "Add people" and entered Jasmine's GitHub username ๐ฉโ๐ป
- I've sent an invitation with a message: "In collaboration with Jasmine for the Git assignment" ๐จ
- I've waited for Jasmine to accept the invitation โ
-
๐ฑ Create Feature Branch
git checkout -b feature/sqrt -
โ Add Square Root Method I've added the square root method:
def square_root(self, x): return math.sqrt(x) # Add to main section: num3 = 25 print(f"The square root of {num3} = {calculator.square_root(num3)}")
-
๐พ Commit & Push Feature
git add . git commit -m "Implement square root function" git push origin feature/sqrt -
๐ Fix Bug in Dev Branch
git checkout dev git pull origin devI've updated the divide method:
def divide(self, a, b): if b == 0: raise ValueError("Cannot divide by zero.") return a / b
git add . git commit -m "Fix divide by zero bug" git push origin dev -
๐ Update Feature Branch
git checkout feature/sqrt git merge dev git push origin feature/sqrt -
๐ Create Pull Request
- I've gone to GitHub โ Pull Requests โ New Pull Request ๐
- Base:
devโ Compare:feature/sqrt - I've created a PR with a detailed description ๐
- I've requested Jasmine to review the PR ๐
-
๐ Merge to Dev After Approval
git checkout dev git merge feature/sqrt git push origin dev -
๐ท๏ธ Release v2.0
git checkout main git merge dev git push origin main git tag v2.0 git push origin v2.0
๐ฅ๏ธ Windows:
git lfs install
๐ง Linux/Ubuntu:
sudo apt install git-lfs
git lfs install
-
๐ฅ Clone & Create Branch
git clone https://github.com/yourusername/git_assignment_HeroVired.git cd git_assignment_HeroVired git checkout -b lfs -
โ๏ธ Configure File Tracking
git lfs track "*.zip" # or track specific file: git lfs track "IDM.zip" -
๐ค Add & Commit Files I've added:
git add .gitattributes git add IDM.zip git commit -m "Added large file using Git LFS" git push origin lfs -
โ Verify LFS Tracking
git lfs ls-files -
๐งช Test Clone on Another Machine
git clone https://github.com/yourusername/git_assignment_HeroVired.git cd git_assignment_HeroVired git checkout lfs git lfs pull
-
๐ฅ Clone & Create Base Branch
git clone https://github.com/yourusername/git_assignment_HeroVired.git cd git_assignment_HeroVired git checkout main git checkout -b geometry-calculator -
๐ป Create Base Calculator I've created
geometry_calculator.py:import math class GeometryCalculator: def calculate_circle_area(self, radius): return math.pi * radius ** 2 def calculate_rectangle_area(self, length, width): return length * width if __name__ == "__main__": calculator = GeometryCalculator()
-
๐ฑ Create Feature Branch
git checkout -b feature/circle-area -
๐ด Implement Circle Area I've added to the main section:
radius = 5 print(f"The area of the circle with radius {radius} = {calculator.calculate_circle_area(radius)}")
-
๐พ Save Work in Progress
git stash git status # verify clean working directory
-
๐ฑ Create Feature Branch
git checkout -b feature/rectangle-area -
๐ Implement Rectangle Area I've added to the main section:
length = 10 width = 6 print(f"The area of the rectangle with length {length} and width {width} = {calculator.calculate_rectangle_area(length, width)}")
-
๐พ Save Work in Progress
git stash git status # verify clean working directory
-
โญ Complete Circle Feature
git checkout feature/circle-area git stash pop git add . git commit -m "Implemented circle area calculation" git push origin feature/circle-area -
๐ Complete Rectangle Feature
git checkout feature/rectangle-area git stash pop git add . git commit -m "Implemented rectangle area calculation" git push origin feature/rectangle-area -
๐ Create Pull Requests
- I've created a PR:
feature/circle-areaโdev๐ - I've created a PR:
feature/rectangle-areaโdev๐
- I've created a PR:
-
๐ Code Review Process
- I've requested Jasmine to review my PRs ๐
- I've added a comment: "In collaboration with Jasmine" ๐ฌ
- I've addressed feedback from Jasmine ๐
- I've merged PRs to
devafter approval โ
-
๐ Final Integration
git checkout main git merge dev git push origin main
| Step | Command | Purpose |
|---|---|---|
| ๐ฅ Clone repository | git clone |
Get local copy |
| ๐ Create calculator branch | git checkout -b geometry-calculator |
Base branch |
| โญ Create circle feature | git checkout -b feature/circle-area |
Feature branch |
| ๐พ Save circle changes | git stash |
Store temporarily |
| ๐ Create rectangle feature | git checkout -b feature/rectangle-area |
Feature branch |
| ๐พ Save rectangle changes | git stash |
Store temporarily |
| โญ Complete circle feature | git checkout feature/circle-area && git stash pop |
Resume work |
| ๐ค Push circle feature | git push origin feature/circle-area |
Share with team |
| ๐ Complete rectangle feature | git checkout feature/rectangle-area && git stash pop |
Resume work |
| ๐ค Push rectangle feature | git push origin feature/rectangle-area |
Share with team |
| ๐ Review & merge | Pull Requests | Quality control |
| ๐ Release | Merge to main | Production ready |
The area of the circle with radius 5 = 78.53981633974483
The area of the rectangle with length 10 and width 6 = 60
Throughout this project, I've worked closely with Jasmine to implement the Git workflow and features. Jasmine has:
- ๐ Reviewed my pull requests for the calculator features
- ๐ฌ Provided feedback on my code implementation
- ๐งช Helped test the geometry calculator functionality
- ๐ฆ Collaborated on the Git LFS setup
This collaboration demonstrates effective teamwork using Git's branching and review features, allowing us to work independently while maintaining code quality through peer reviews. ๐