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
- Open VS Code
- File → "Open Folder" → Create new folder:
data_analysis_project
- Open integrated terminal: `Ctrl+`` (backtick)
- Run:
git init
- Configure Git (one-time setup):
git config --global user.name "Your Name"
git config --global user.email "[email protected]"
Initialize Repository: GitHub
- Go to github.com and click "+" → "New repository"
- Name:
data_analysis_project
- Description: "DataSci 217 - Git workflow demonstration"
- Make it public
- DO NOT initialize with README, .gitignore, or license
- Click "Create repository"
- 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
- Create folders:
data, scripts, results
- Create files:
README.md, scripts/analysis.py, data/sample_data.csv
- Open
README.md and add content:
# Data Analysis Project
This project demonstrates Git workflow.
Create Initial Files: GitHub
- Go to your repository on GitHub
- Click "Add file" → "Create new file"
- Name:
README.md
- Add content:
# Data Analysis Project
This project demonstrates Git workflow.
- Commit message: "Add initial README"
- 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
- Open VS Code in your project directory:
code .
- Open Source Control panel:
Ctrl+Shift+G (Windows/Linux) or Cmd+Shift+G (Mac)
- You should see your files listed under "Changes"
- Stage files by clicking the
+ button next to each file
- Type commit message: "Initial project setup"
- Press
Ctrl+Enter (Windows/Linux) or Cmd+Enter (Mac) to commit
- Make a change to README.md and watch the diff appear in VS Code
Initial Commit: GitHub
- Go to your repository on GitHub
- Click "Add file" → "Create new file"
- Name:
scripts/analysis.py
- Add content:
print("Hello from GitHub!")
- Commit message: "Add analysis script via GitHub"
- 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
- Open Source Control panel:
Ctrl+Shift+G (Windows/Linux) or Cmd+Shift+G (Mac)
- Click "Publish to GitHub" button (if you see it)
- Or click "..." menu → "Publish to GitHub"
- Choose repository name:
data-analysis-project
- Choose visibility: Public or Private
- Click "Publish to GitHub"
- VS Code will automatically push your commits
Publish to GitHub: GitHub
- Go to your existing repository on GitHub
- The repository already exists from Step 1
- Your local changes are already published
- No additional steps needed - the repo is live on GitHub
- 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