|
| 1 | +#!/bin/bash |
1 | 2 |
|
| 3 | +######################################################## |
| 4 | +# 🚀 GIT & GITHUB – LEVEL 1 (BEGINNER) |
| 5 | +# This script explains basic Git + GitHub workflow |
| 6 | +# You can read, copy, and execute commands step by step |
| 7 | +######################################################## |
| 8 | + |
| 9 | + |
| 10 | +############################ |
| 11 | +# 1️⃣ CHECK GIT INSTALLATION |
| 12 | +############################ |
| 13 | +git --version |
| 14 | +# If not installed (Ubuntu): |
| 15 | +# sudo apt install git -y |
| 16 | + |
| 17 | + |
| 18 | +############################ |
| 19 | +# 2️⃣ CONFIGURE GIT (ONE TIME) |
| 20 | +############################ |
| 21 | +git config --global user.name "Your Name" |
| 22 | +git config --global user.email "your-email@gmail.com" |
| 23 | + |
| 24 | +# Verify config |
| 25 | +git config --list |
| 26 | + |
| 27 | + |
| 28 | +############################ |
| 29 | +# 3️⃣ CREATE A PROJECT FOLDER |
| 30 | +############################ |
| 31 | +mkdir Devops |
| 32 | +cd Devops |
| 33 | + |
| 34 | + |
| 35 | +############################ |
| 36 | +# 4️⃣ INITIALIZE GIT REPO |
| 37 | +############################ |
| 38 | +git init |
| 39 | +# Creates .git folder (Git starts tracking) |
| 40 | + |
| 41 | + |
| 42 | +############################ |
| 43 | +# 5️⃣ CREATE A FILE |
| 44 | +############################ |
| 45 | +echo "Hello DevOps" > README.md |
| 46 | +ls |
| 47 | + |
| 48 | + |
| 49 | +############################ |
| 50 | +# 6️⃣ CHECK GIT STATUS |
| 51 | +############################ |
| 52 | +git status |
| 53 | +# Shows untracked / modified files |
| 54 | + |
| 55 | + |
| 56 | +############################ |
| 57 | +# 7️⃣ ADD FILES TO STAGING AREA |
| 58 | +############################ |
| 59 | +git add README.md |
| 60 | +# OR add all files: |
| 61 | +# git add . |
| 62 | + |
| 63 | + |
| 64 | +############################ |
| 65 | +# 8️⃣ COMMIT CHANGES |
| 66 | +############################ |
| 67 | +git commit -m "Initial commit" |
| 68 | +# Saves snapshot to local repo |
| 69 | + |
| 70 | + |
| 71 | +############################ |
| 72 | +# 9️⃣ CREATE GITHUB REPOSITORY |
| 73 | +############################ |
| 74 | +# Go to GitHub → New Repository → Create repo (NO README) |
| 75 | +# Copy the repo URL |
| 76 | + |
| 77 | + |
| 78 | +############################ |
| 79 | +# 🔟 ADD REMOTE ORIGIN |
| 80 | +############################ |
| 81 | +git remote add origin https://github.com/username/Devops.git |
| 82 | + |
| 83 | +# Verify remote |
| 84 | +git remote -v |
| 85 | + |
| 86 | + |
| 87 | +############################ |
| 88 | +# 1️⃣1️⃣ PUSH CODE TO GITHUB |
| 89 | +############################ |
| 90 | +git branch -M main |
| 91 | +git push -u origin main |
| 92 | + |
| 93 | + |
| 94 | +############################ |
| 95 | +# 1️⃣2️⃣ CLONE A REPOSITORY |
| 96 | +############################ |
| 97 | +# git clone https://github.com/username/Devops.git |
| 98 | + |
| 99 | + |
| 100 | +############################ |
| 101 | +# 1️⃣3️⃣ CREATE A NEW BRANCH |
| 102 | +############################ |
| 103 | +git checkout -b feature-shell-script |
| 104 | +# OR |
| 105 | +# git branch feature-shell-script |
| 106 | +# git checkout feature-shell-script |
| 107 | + |
| 108 | + |
| 109 | +############################ |
| 110 | +# 1️⃣4️⃣ MAKE CHANGES IN BRANCH |
| 111 | +############################ |
| 112 | +echo "Shell scripting basics" >> README.md |
| 113 | +git add . |
| 114 | +git commit -m "Added shell scripting info" |
| 115 | + |
| 116 | + |
| 117 | +############################ |
| 118 | +# 1️⃣5️⃣ PUSH BRANCH TO GITHUB |
| 119 | +############################ |
| 120 | +git push origin feature-shell-script |
| 121 | + |
| 122 | + |
| 123 | +############################ |
| 124 | +# 1️⃣6️⃣ CREATE PULL REQUEST (PR) |
| 125 | +############################ |
| 126 | +# Go to GitHub → Compare & Pull Request |
| 127 | +# Add title and description → Create PR |
| 128 | + |
| 129 | + |
| 130 | +############################ |
| 131 | +# 1️⃣7️⃣ PULL LATEST CHANGES |
| 132 | +############################ |
| 133 | +git checkout main |
| 134 | +git pull origin main |
| 135 | + |
| 136 | + |
| 137 | +############################ |
| 138 | +# 1️⃣8️⃣ GIT LOG (HISTORY) |
| 139 | +############################ |
| 140 | +git log --oneline |
| 141 | + |
| 142 | + |
| 143 | +############################ |
| 144 | +# 1️⃣9️⃣ GIT DIFF (CHANGES) |
| 145 | +############################ |
| 146 | +git diff |
| 147 | + |
| 148 | + |
| 149 | +############################ |
| 150 | +# 2️⃣0️⃣ DELETE A BRANCH |
| 151 | +############################ |
| 152 | +git branch -d feature-shell-script |
| 153 | +git push origin --delete feature-shell-script |
| 154 | + |
| 155 | + |
| 156 | +######################################################## |
| 157 | +# ✅ END OF GIT & GITHUB LEVEL 1 |
| 158 | +######################################################## |
0 commit comments