Unit 6 - Notes

CSE111

Unit 6: Version Control

1. Overview of Git and GitHub

What is Version Control?

Version control is a system that records changes to a file or set of files over time so that you can recall specific versions later. It allows multiple developers to collaborate on a project without overwriting each other's work.

Git

Git is a distributed version control system (DVCS).

  • Distributed: Every developer has a full copy of the repository, including the entire history of all changes.
  • Speed: Operations are performed locally, making it extremely fast.
  • Snapshots: Unlike other systems that store changes as a list of file-based changes, Git thinks of its data more like a series of snapshots of a miniature filesystem.

GitHub

GitHub is a cloud-based hosting service for Git repositories.

  • Collaboration: It provides a web-based graphical interface and access control and several collaboration features (wikis, task management, bug tracking).
  • Social Coding: It acts as a portfolio for developers to showcase their work.
Feature Git GitHub
Type Software (Tool) Service (Website)
Location Installed locally on computer Hosted on the Web (Cloud)
Usage Version control management Hosting, code review, collaboration
Dependency Can be used without GitHub Requires Git to upload code

2. Setting Up the Environment

Installing Git

  • Windows: Download the installer from git-scm.com. Run the .exe file and follow the prompts (typically keeping default settings).
  • macOS: Install via Homebrew (brew install git) or download the installer.
  • Linux: Use the package manager (e.g., sudo apt-get install git).

Verification:
Open your terminal or command prompt and type:

BASH
git --version

Creating a GitHub Account

  1. Navigate to github.com.
  2. Click Sign Up.
  3. Enter a valid email address, create a strong password, and choose a username (this will be your public identity).
  4. Verify your account via the email sent to you.

Configuration

Before using Git, configure your global identity (used for commit logs):

BASH
git config --global user.name "Your Name"
git config --global user.email "your_email@example.com"


3. Basic Git Operations

Creating a Local Git Repository

To start tracking a project with Git, you must initialize a repository.

  1. Create a folder for your project.
  2. Open the terminal in that folder.
  3. Run the command:
    BASH
        git init
        
    • Result: This creates a hidden subfolder named .git that contains all necessary repository metadata.

Adding a New File

Git has a three-stage architecture: Working Directory Staging Area Repository.

  1. Create a file: Create a text file named hello.txt with some content.
  2. Check Status:
    BASH
        git status
        
    • Result: Shows the file is "Untracked".
  3. Add to Staging:
    BASH
        git add hello.txt
        
    • Result: The file is now in the Staging Area, ready to be committed. (Use git add . to add all changed files).

Creating a Commit

A commit is a snapshot of your project at a specific point in time. It saves the changes currently in the Staging Area to the local repository.

BASH
git commit -m "Initial commit: Added hello.txt"

  • -m: Stands for "message". Always include a descriptive message explaining what changed.

4. Branching

Creation of a New Branch

Branching allows you to diverge from the main line of development and continue to do work without messing with that main line.

  • Master/Main: The default branch where stable code lives.
  • Feature Branch: A temporary branch used to develop a specific feature.

Commands:

  1. List branches:

    BASH
        git branch
        

  2. Create a new branch:

    BASH
        git branch feature-login
        

  3. Switch to the new branch:

    BASH
        git checkout feature-login
        

    (Or use the shorthand in newer Git versions: git switch feature-login)

  4. Create and switch simultaneously:

    BASH
        git checkout -b feature-login
        

Once changes are made on the branch, they can be merged back into the main branch using git merge.


5. Introduction to AI and Real-Life Applications

What is AI?

Artificial Intelligence (AI) refers to the simulation of human intelligence in machines that are programmed to think like humans and mimic their actions. It involves learning (acquiring information), reasoning (using rules to reach conclusions), and self-correction.

Real-Life Applications

  1. Healthcare: IBM Watson for oncology (diagnosing cancer), analyzing X-rays, predicting patient risk factors.
  2. Finance: Fraud detection algorithms, algorithmic trading, credit scoring.
  3. Transportation: Autonomous vehicles (Tesla Autopilot), traffic prediction (Google Maps).
  4. E-commerce: Product recommendation engines (Amazon, Netflix), customer service chatbots.
  5. Social Media: Content moderation, facial recognition tagging (Facebook), feed personalization (TikTok algorithms).

6. Generative AI

Introduction

Generative AI is a subset of artificial intelligence focused on creating new content (text, images, audio, video, code) rather than simply analyzing or classifying existing data. It learns patterns from training data and generates new outputs with similar characteristics.

Types of Generative Models

  1. Large Language Models (LLMs): Statistical models designed to understand and generate text (e.g., GPT-4, Claude).
  2. Diffusion Models: Used primarily for image generation. They work by adding noise to an image until it is static, then learning to reverse the process to create a clear image from noise (e.g., Stable Diffusion).
  3. GANs (Generative Adversarial Networks): Consists of two neural networks—a Generator (creates content) and a Discriminator (judges if it is real or fake)—competing against each other to improve quality.

Generative AI Tools

Text Generation

  • ChatGPT (OpenAI): Conversational AI for coding, writing, and analysis.
  • Claude (Anthropic): Known for handling large amounts of text context and safety.
  • Gemini (Google): Multimodal model integrated into the Google ecosystem.

Image Generation

  • Midjourney: Generates high-artistic quality images via Discord.
  • DALL-E 3: OpenAI’s image generator, known for adhering closely to complex prompts.
  • Stable Diffusion: Open-source model capable of running locally.

Video and Animation Tools

  • Sora (OpenAI): Text-to-video model creating realistic scenes.
  • Runway Gen-2: AI tools for film editing and generation.
  • Synthesia: Creates AI avatars for presentation videos.

7. AI Research Tools

These tools specialize in academic and technical research, prioritizing accuracy and citation over creative writing.

  1. Perplexity AI:
    • A conversational search engine.
    • Unlike ChatGPT, it browses the live internet to provide answers with direct citations and sources.
  2. NotebookLM (Google):
    • A personalized AI research assistant.
    • Users upload their own documents (PDFs, Google Docs). The AI creates summaries, answers questions, and generates audio discussions based only on the uploaded source material (reducing hallucinations).
  3. JenniAI:
    • An AI writing assistant specifically for academic research.
    • Features include autocomplete, citation generation, and plagiarism checking.

8. Prompt Engineering

Definition

Prompt Engineering is the practice of designing and refining inputs (prompts) to generative AI models to elicit specific, high-quality outputs.

Good vs. Poor Prompts

Feature Poor Prompt Good Prompt
Specificity "Write code for a calculator." "Write a Python function for a calculator that handles addition, subtraction, multiplication, and division, including error handling for division by zero."
Context "Explain AI." "Explain Generative AI to a high school student using analogies related to art and cooking."
Constraints "Write an email." "Write a formal email to a recruiter declined a job offer. Keep it under 100 words and maintain a polite tone."

Framework for Good Prompts (CREATE):

  • Context (Who is the AI acting as?)
  • Request (What is the task?)
  • Example (Show the AI what you want)
  • Audience (Who is this for?)
  • Tone (Formal, casual, etc.)
  • Extra constraints (Length, format)

Ethical Use of AI

  1. Plagiarism: AI should be used to brainstorm or refine, not to generate entire assignments submitted as one's own work.
  2. Bias: AI models can perpetuate biases found in their training data (gender, race, culture). Users must critically evaluate outputs.
  3. Hallucination: AI can confidently state facts that are false. Verification is mandatory.
  4. Data Privacy: Do not input sensitive personal or proprietary company data into public AI models.

9. Profile Creation and Professional Platforms

Building a digital presence is crucial for computing professionals.

Design & Collaboration

  • Figma: A cloud-based design tool for UI/UX.
    • Profile Usage: Showcase interface designs, prototypes, and wireframes.

Code Hosting & Portfolio

  • GitHub:
    • Profile Usage: The primary portfolio for developers. Green contribution squares indicate activity. Key projects should be pinned to the profile with good README.md documentation.

Knowledge Sharing

  • Stack Overflow:
    • Profile Usage: A Q&A platform. A high reputation score indicates a developer who helps others and has deep technical knowledge.

Coding Practice & Competitive Programming

These platforms are used for skill verification and interview preparation:

  1. HackerRank: Used by companies for technical assessments. Badges earned here validate skills in Python, Java, SQL, etc.
  2. HackerEarth: Hosts hackathons and coding challenges. Good for innovation and enterprise-level challenges.
  3. GeeksforGeeks: A computer science portal. Profiles track problems solved and articles read/written.
  4. LeetCode: The industry standard for Data Structures and Algorithms (DSA) interview prep.
    • Profile Usage: Solved count (Easy/Medium/Hard) and contest ratings are often looked at by FAANG recruiters.