cd Desktop
mkdir github-demo
cd github-demo
ls
git config --global user.name "Deepak Dubey"
git config --global user.email "learnpde@gmail.com"
git --version
Lab Demo Token
demo-repo-scenario1
git clone https://github.com/learnpde/demo-repo-scenario1.git
cd demo-repo-scenario1
ls -la
git status
echo "console.log('Hello from Scenario 1!');" > app.js
cat > package.json << EOF
{
"name": "demo-repo-scenario1",
"version": "1.0.0",
"description": "Demo repository for GitHub hands-on lab",
"main": "app.js",
"scripts": {
"start": "node app.js"
}
}
EOF
git status
git add app.js package.json
git commit -m "Add initial application files and package.json"
git push origin main
export GITHUB_TOKEN=your_token_here
git push "https://${GITHUB_TOKEN}@github.com/learnpde/demo-repo-scenario1.git" main
git log --oneline
mkdir -p ~/.ssh
chmod 700 ~/.ssh
cd ~/.ssh
ssh-keygen -t ed25519 -C "learnpde@gmail.com" -f ~/.ssh/github-demo
cat ~/.ssh/github-demo.pub
Lab Demo SSH Key
chmod 600 ~/.ssh/github-demo
chmod 644 ~/.ssh/github-demo.pub
ssh-add ~/.ssh/github-demo
ssh -T git@github.com
cd ~/Desktop/github-demo
mkdir demo-repo-scenario2
cd demo-repo-scenario2
git init
cat > README.md << EOF
# Demo Repository - Scenario 2
This repository demonstrates creating a local Git repository first, then pushing to GitHub.
## Features
- Local-first development approach
- Essential Git command demonstration
- GitHub integration workflow
## Getting Started
Run the application with:
\`\`\`
python main.py
\`\`\`
EOF
cat > main.py << EOF
#!/usr/bin/env python3
"""
Demo application for GitHub hands-on lab
Scenario 2: Local repository created first
"""
def main():
print("Hello from Scenario 2!")
print("This repository was created locally first.")
# Demonstrate some basic functionality
numbers = [1, 2, 3, 4, 5]
squared = [n**2 for n in numbers]
print(f"Original numbers: {numbers}")
print(f"Squared numbers: {squared}")
if __name__ == "__main__":
main()
EOF
cat > .gitignore << EOF
# Python
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
env/
venv/
.venv/
# IDE
.vscode/
.idea/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
EOF
git add .
git commit -m "Initial commit: Add README, main application, and gitignore"
demo-repo-scenario2
Hands-on demo repository created locally first
Check Nothing
git remote add origin git@github.com:learnpde/demo-repo-scenario2.git
git branch -M main
git remote -v
git push -u origin main
cd ../demo-repo-scenario1
git checkout -b feature/add-functions
git switch -c feature/add-functions
cat > utils.js << EOF
// Utility functions for the demo application
function calculateSum(numbers) {
return numbers.reduce((sum, num) => sum + num, 0);
}
function calculateAverage(numbers) {
return numbers.length > 0 ? calculateSum(numbers) / numbers.length : 0;
}
function findMax(numbers) {
return Math.max(...numbers);
}
module.exports = {
calculateSum,
calculateAverage,
findMax
};
EOF
cat > app.js << EOF
const { calculateSum, calculateAverage, findMax } = require('./utils');
console.log('Hello from Scenario 1!');
// Demo the utility functions
const numbers = [10, 25, 30, 15, 40];
console.log('Numbers:', numbers);
console.log('Sum:', calculateSum(numbers));
console.log('Average:', calculateAverage(numbers));
console.log('Maximum:', findMax(numbers));
EOF
git add .
git commit -m "Add utility functions and update main application"
git push -u origin feature/add-functions
Add utility functions and update main application
Add Detailed Description here
Merge pull request #1 from learnpde/feature/add-functions
git switch main
ls -la
git pull origin main
git branch -d feature/add-functions
## Recent Updates
- Added collaborative workflow demonstration
- Updated: [Current Date]
Update README with collaboration info
cd ../demo-repo-scenario2
cat README.md
git pull origin main
cat README.md
git config --list
cd ..
git clone https://github.com/learnpde/demo-repo-scenario1.git test-clone
cd test-clone
node app.js
cd ../demo-repo-scenario2
python3 main.py
cd ..
rm -rf demo-repo-scenario1 demo-repo-scenario2 test-clone
learnpde/demo-repo-scenario1
learnpde/demo-repo-scenario2
rm ~/.ssh/github-demo
rm ~/.ssh/github-demo.pub
ls github-demo github-demo.pub