cd Desktop
mkdir github-demo
cd github-demo
lsgit config --global user.name "Deepak Dubey"
git config --global user.email "learnpde@gmail.com"
git --versionLab Demo Tokendemo-repo-scenario1git clone https://github.com/learnpde/demo-repo-scenario1.git
cd demo-repo-scenario1ls -lagit statusecho "console.log('Hello from Scenario 1!');" > app.jscat > 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"
}
}
EOFgit statusgit add app.js package.jsongit commit -m "Add initial application files and package.json"git push origin mainexport GITHUB_TOKEN=your_token_heregit push "https://${GITHUB_TOKEN}@github.com/learnpde/demo-repo-scenario1.git" maingit log --onelinemkdir -p ~/.ssh
chmod 700 ~/.sshcd ~/.sshssh-keygen -t ed25519 -C "learnpde@gmail.com" -f ~/.ssh/github-democat ~/.ssh/github-demo.pubLab Demo SSH Keychmod 600 ~/.ssh/github-demo
chmod 644 ~/.ssh/github-demo.pubssh-add ~/.ssh/github-demossh -T git@github.comcd ~/Desktop/github-demo
mkdir demo-repo-scenario2
cd demo-repo-scenario2git initcat > 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
\`\`\`
EOFcat > 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()
EOFcat > .gitignore << EOF
# Python
__pycache__/
*.pyc
*.pyo
*.pyd
.Python
env/
venv/
.venv/
# IDE
.vscode/
.idea/
*.swp
*.swo
# OS
.DS_Store
Thumbs.db
EOFgit add .git commit -m "Initial commit: Add README, main application, and gitignore"demo-repo-scenario2Hands-on demo repository created locally firstCheck Nothing
git remote add origin git@github.com:learnpde/demo-repo-scenario2.gitgit branch -M maingit remote -vgit push -u origin maincd ../demo-repo-scenario1git checkout -b feature/add-functionsgit switch -c feature/add-functionscat > 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
};
EOFcat > 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));
EOFgit add .git commit -m "Add utility functions and update main application"git push -u origin feature/add-functionsAdd utility functions and update main applicationAdd Detailed Description hereMerge pull request #1 from learnpde/feature/add-functionsgit switch mainls -lagit pull origin maingit branch -d feature/add-functions## Recent Updates
- Added collaborative workflow demonstration
- Updated: [Current Date]Update README with collaboration infocd ../demo-repo-scenario2cat README.mdgit pull origin maincat README.mdgit config --listcd ..git clone https://github.com/learnpde/demo-repo-scenario1.git test-clonecd test-clonenode app.jscd ../demo-repo-scenario2python3 main.pycd ..rm -rf demo-repo-scenario1 demo-repo-scenario2 test-clonelearnpde/demo-repo-scenario1learnpde/demo-repo-scenario2rm ~/.ssh/github-demo
rm ~/.ssh/github-demo.publs github-demo github-demo.pub