Skip to content

Latest commit

ย 

History

16 Commits

Folders and files

NameName
Last commit message
Last commit date
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

๐Ÿš€ Git Assignment Guide

๐Ÿ“‹ Project Description

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.

๐Ÿ› ๏ธ Prerequisites

  • โœจ Git installed on your local machine
  • ๐ŸŒ GitHub account
  • ๐Ÿ Basic knowledge of Python
  • ๐Ÿ“ฆ Git LFS installed (for Question 2)
  • ๐Ÿ’ป Access to terminal or command prompt

๐Ÿ“ Project Structure

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

๐ŸŒฟ Branches

  • ๐ŸŸข main (default)
  • ๐Ÿ› ๏ธ dev
  • ๐Ÿ”ด feature/circle-area
  • ๐Ÿ“ feature/rectangle-area
  • ๐Ÿงฎ feature/sqrt
  • ๐Ÿ“ geometry-calculator
  • ๐Ÿ“ฆ lfs

โœ… Question 1: Setup & Basic Git Workflow

๐Ÿ“ Create a GitHub Repository

  1. ๐Ÿ”‘ Login to GitHub

    • Navigate to GitHub.com and sign in
    • Click the "+" in top-right corner โ†’ "New repository"
  2. โš™๏ธ Configure Repository

    • Name: git_assignment_HeroVired
    • Visibility: Private
    • โœ… Initialize with README
  3. ๐Ÿ“ฅ Clone to Local Machine

    git clone https://github.com/yourusername/git_assignment_HeroVired.git
    cd git_assignment_HeroVired
    
  4. ๐ŸŒฑ Create Development Branch

    git checkout -b dev
    
  5. ๐Ÿ’ป 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)}")
  6. ๐Ÿ“ค Commit & Push Changes

    git add .
    git commit -m "Added initial calculator code"
    git push origin dev
    
  7. ๐Ÿ”„ Merge & Tag Release v1.0

    git checkout main
    git merge dev
    git push origin main
    git tag v1.0
    git push origin v1.0
    

๐Ÿ‘ฅ Add a Collaborator

  1. I've gone to repository โ†’ Settings โ†’ Collaborators โš™๏ธ
  2. I've clicked "Add people" and entered Jasmine's GitHub username ๐Ÿ‘ฉโ€๐Ÿ’ป
  3. I've sent an invitation with a message: "In collaboration with Jasmine for the Git assignment" ๐Ÿ“จ
  4. I've waited for Jasmine to accept the invitation โœ…

๐Ÿงฎ Add Square Root Feature

  1. ๐ŸŒฑ Create Feature Branch

    git checkout -b feature/sqrt
    
  2. โž• 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)}")
  3. ๐Ÿ’พ Commit & Push Feature

    git add .
    git commit -m "Implement square root function"
    git push origin feature/sqrt
    
  4. ๐Ÿ› Fix Bug in Dev Branch

    git checkout dev
    git pull origin dev
    

    I'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
    
  5. ๐Ÿ”„ Update Feature Branch

    git checkout feature/sqrt
    git merge dev
    git push origin feature/sqrt
    
  6. ๐Ÿ”€ 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 ๐Ÿ‘€
  7. ๐Ÿ”€ Merge to Dev After Approval

    git checkout dev
    git merge feature/sqrt
    git push origin dev
    
  8. ๐Ÿท๏ธ Release v2.0

    git checkout main
    git merge dev
    git push origin main
    git tag v2.0
    git push origin v2.0
    

๐Ÿ“ฆ Question 2: Git LFS for Large Files

๐Ÿ’ฟ Install Git LFS

๐Ÿ–ฅ๏ธ Windows:

git lfs install

๐Ÿง Linux/Ubuntu:

sudo apt install git-lfs
git lfs install

๐Ÿ—ƒ๏ธ Setup Repository for LFS

  1. ๐Ÿ“ฅ Clone & Create Branch

    git clone https://github.com/yourusername/git_assignment_HeroVired.git
    cd git_assignment_HeroVired
    git checkout -b lfs
    
  2. โš™๏ธ Configure File Tracking

    git lfs track "*.zip"
    # or track specific file:
    git lfs track "IDM.zip"
    
  3. ๐Ÿ“ค 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
    
  4. โœ… Verify LFS Tracking

    git lfs ls-files
    
  5. ๐Ÿงช 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
    

๐Ÿ“ Question 3: Geometry Calculator with Feature Branches

๐Ÿ—๏ธ Initial Setup

  1. ๐Ÿ“ฅ 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
    
  2. ๐Ÿ’ป 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()

โญ• Circle Area Feature

  1. ๐ŸŒฑ Create Feature Branch

    git checkout -b feature/circle-area
    
  2. ๐Ÿ”ด 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)}")
  3. ๐Ÿ’พ Save Work in Progress

    git stash
    git status  # verify clean working directory
    

๐Ÿ“ Rectangle Area Feature

  1. ๐ŸŒฑ Create Feature Branch

    git checkout -b feature/rectangle-area
    
  2. ๐Ÿ“ 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)}")
  3. ๐Ÿ’พ Save Work in Progress

    git stash
    git status  # verify clean working directory
    

๐Ÿ”„ Complete & Submit Features

  1. โญ• 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
    
  2. ๐Ÿ“ 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
    
  3. ๐Ÿ”€ Create Pull Requests

    • I've created a PR: feature/circle-area โ†’ dev ๐Ÿ“
    • I've created a PR: feature/rectangle-area โ†’ dev ๐Ÿ“
  4. ๐Ÿ‘€ 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 dev after approval โœ…
  5. ๐Ÿš€ Final Integration

    git checkout main
    git merge dev
    git push origin main
    

๐Ÿ“‹ Workflow Summary

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

๐Ÿ“Š Expected Output

The area of the circle with radius 5 = 78.53981633974483
The area of the rectangle with length 10 and width 6 = 60

๐Ÿค Collaboration

In collaboration with Jasmine ๐Ÿ‘ฉโ€๐Ÿ’ป

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. ๐ŸŒŸ

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages