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
.exefile 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:
git --version
Creating a GitHub Account
- Navigate to github.com.
- Click Sign Up.
- Enter a valid email address, create a strong password, and choose a username (this will be your public identity).
- Verify your account via the email sent to you.
Configuration
Before using Git, configure your global identity (used for commit logs):
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.
- Create a folder for your project.
- Open the terminal in that folder.
- Run the command:
BASHgit init- Result: This creates a hidden subfolder named
.gitthat contains all necessary repository metadata.
- Result: This creates a hidden subfolder named
Adding a New File
Git has a three-stage architecture: Working Directory Staging Area Repository.
- Create a file: Create a text file named
hello.txtwith some content. - Check Status:
BASHgit status- Result: Shows the file is "Untracked".
- Add to Staging:
BASHgit add hello.txt- Result: The file is now in the Staging Area, ready to be committed. (Use
git add .to add all changed files).
- Result: The file is now in the Staging Area, ready to be committed. (Use
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.
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:
-
List branches:
BASHgit branch -
Create a new branch:
BASHgit branch feature-login -
Switch to the new branch:
BASHgit checkout feature-login
(Or use the shorthand in newer Git versions:git switch feature-login) -
Create and switch simultaneously:
BASHgit 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
- Healthcare: IBM Watson for oncology (diagnosing cancer), analyzing X-rays, predicting patient risk factors.
- Finance: Fraud detection algorithms, algorithmic trading, credit scoring.
- Transportation: Autonomous vehicles (Tesla Autopilot), traffic prediction (Google Maps).
- E-commerce: Product recommendation engines (Amazon, Netflix), customer service chatbots.
- 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
- Large Language Models (LLMs): Statistical models designed to understand and generate text (e.g., GPT-4, Claude).
- 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).
- 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.
- Perplexity AI:
- A conversational search engine.
- Unlike ChatGPT, it browses the live internet to provide answers with direct citations and sources.
- 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).
- 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
- Plagiarism: AI should be used to brainstorm or refine, not to generate entire assignments submitted as one's own work.
- Bias: AI models can perpetuate biases found in their training data (gender, race, culture). Users must critically evaluate outputs.
- Hallucination: AI can confidently state facts that are false. Verification is mandatory.
- 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.mddocumentation.
- Profile Usage: The primary portfolio for developers. Green contribution squares indicate activity. Key projects should be pinned to the profile with good
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:
- HackerRank: Used by companies for technical assessments. Badges earned here validate skills in Python, Java, SQL, etc.
- HackerEarth: Hosts hackathons and coding challenges. Good for innovation and enterprise-level challenges.
- GeeksforGeeks: A computer science portal. Profiles track problems solved and articles read/written.
- 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.