Demo 1: Git & GitHub Workflow

Step 1: Initialize Repository - Three Ways

Initialize Repository: Command Line

# Create project directory
mkdir data_analysis_project
cd data_analysis_project

# Initialize Git repository
git init
git status

# Configure Git (one-time setup)
git config --global user.name "Your Name"
git config --global user.email "Develop features on separate branches"

Initialize Repository: VS Code

  1. Open VS Code
  2. File → "Open Folder" → Create new folder: data_analysis_project
  3. Open integrated terminal: `Ctrl+`` (backtick)
  4. Run: git init
  5. Configure Git (one-time setup):

Initialize Repository: GitHub

  1. Go to github.com and click "+" → "New repository"
  2. Name: data_analysis_project
  3. Description: "DataSci 217 - Git workflow demonstration"
  4. Make it public
  5. DO NOT initialize with README, .gitignore, or license
  6. Click "Create repository"
  7. Click "Code" → "Clone" → Copy the repository URL

Step 2: Create Initial Files - Three Ways

Create Initial Files: Command Line

# Create directory structure
mkdir data scripts results

# Create initial files
touch README.md scripts/analysis.py data/sample_data.csv

# Add some content to README.md
echo "# Data Analysis Project" > README.md
echo "This project demonstrates Git workflow." >> README.md

Create Initial Files: VS Code

  1. Create folders: data, scripts, results
  2. Create files: README.md, scripts/analysis.py, data/sample_data.csv
  3. Open README.md and add content:
# Data Analysis Project
This project demonstrates Git workflow.

Create Initial Files: GitHub

  1. Go to your repository on GitHub
  2. Click "Add file" → "Create new file"
  3. Name: README.md
  4. Add content:
# Data Analysis Project
This project demonstrates Git workflow.

  1. Commit message: "Add initial README"
  2. Click "Commit new file"

Step 3: Initial Commit - Three Ways

Initial Commit: Command Line

# Stage all files
git add .

# Commit with message
git commit -m "Initial project setup"

# Check status
git status

Initial Commit: VS Code

  1. Open VS Code in your project directory: code .
  2. Open Source Control panel: Ctrl+Shift+G (Windows/Linux) or Cmd+Shift+G (Mac)
  3. You should see your files listed under "Changes"
  4. Stage files by clicking the + button next to each file
  5. Type commit message: "Initial project setup"
  6. Press Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) to commit
  7. Make a change to README.md and watch the diff appear in VS Code

Initial Commit: GitHub

  1. Go to your repository on GitHub
  2. Click "Add file" → "Create new file"
  3. Name: scripts/analysis.py
  4. Add content: print("Hello from GitHub!")
  5. Commit message: "Add analysis script via GitHub"
  6. Click "Commit new file"

Step 4: Publish to GitHub - Three Ways

Publish to GitHub: Command Line

# Add GitHub as remote origin
git remote add origin <https://github.com/YOUR_USERNAME/data-analysis-project.git>

# Push your local commits to GitHub
git push -u origin main

# Verify connection
git remote -v

Publish to GitHub: VS Code

  1. Open Source Control panel: Ctrl+Shift+G (Windows/Linux) or Cmd+Shift+G (Mac)
  2. Click "Publish to GitHub" button (if you see it)
  3. Or click "..." menu → "Publish to GitHub"
  4. Choose repository name: data-analysis-project
  5. Choose visibility: Public or Private
  6. Click "Publish to GitHub"
  7. VS Code will automatically push your commits

Publish to GitHub: GitHub

  1. Go to your existing repository on GitHub
  2. The repository already exists from Step 1
  3. Your local changes are already published
  4. No additional steps needed - the repo is live on GitHub
  5. Bask in your glory

Step 5: View Git History - Three Ways

Step 6: Create a Branch - Three Ways

Step 7: Merging Branches - Three Ways

Step 8: Undo Uncommitted Changes - Three Ways

Step 9: Pull Changes (Simulate Collaboration) - Three Ways

Step 10: Rolling Back Commits - Three Ways