Sakib Bin Ehsan’s Post

🚀 𝗚𝗜𝗧 𝗧𝗜𝗣𝗦 – 𝗛𝗼𝘄 𝘁𝗼 𝗨𝗻𝗱𝗼 𝗮 𝘨𝘪𝘵 𝘢𝘥𝘥 (𝗪𝗶𝘁𝗵𝗼𝘂𝘁 𝗟𝗼𝘀𝗶𝗻𝗴 𝗬𝗼𝘂𝗿 𝗪𝗼𝗿𝗸!) Ever ran 𝘨𝘪𝘵 𝘢𝘥𝘥 too early and wished you could take it back? 😅 Yeah, you can unstage your files easily without losing your changes! Let’s break it down 👇 💡 When you run: 𝘨𝘪𝘵 𝘢𝘥𝘥 <𝘧𝘪𝘭𝘦_𝘯𝘢𝘮𝘦> ➡️ You’re moving changes to the 𝘀𝘁𝗮𝗴𝗶𝗻𝗴 𝗮𝗿𝗲𝗮 (also called the index). If you want to undo it before committing, you can safely remove files from staging while keeping your edits intact. There are 2 simple ways - 🔥 1️⃣ Using 𝘨𝘪𝘵 𝘳𝘦𝘴𝘵𝘰𝘳𝘦 --𝘴𝘵𝘢𝘨𝘦𝘥 (Recommended for modern Git) To unstage a single file:   ⌨️ 𝘨𝘪𝘵 𝘳𝘦𝘴𝘵𝘰𝘳𝘦 --𝘴𝘵𝘢𝘨𝘦𝘥 <𝘧𝘪𝘭𝘦𝘯𝘢𝘮𝘦> To unstage all files in the current directory:   ⌨️ 𝘨𝘪𝘵 𝘳𝘦𝘴𝘵𝘰𝘳𝘦 --𝘴𝘵𝘢𝘨𝘦𝘥 . ✅ Your edits in <filename> remain — only the staging is undone. It’s like saying, “𝘋𝘰𝘯’𝘵 𝘤𝘰𝘮𝘮𝘪𝘵 𝘵𝘩𝘪𝘴 𝘺𝘦𝘵, 𝘣𝘶𝘵 𝘬𝘦𝘦𝘱 𝘮𝘺 𝘸𝘰𝘳𝘬.” 🔥 2️⃣ Using 𝘨𝘪𝘵 𝘳𝘦𝘴𝘦𝘵 (Classic way) To unstage a single file:   ⌨️ 𝘨𝘪𝘵 𝘳𝘦𝘴𝘦𝘵 <𝘧𝘪𝘭𝘦𝘯𝘢𝘮𝘦> To unstage all files:   ⌨️ 𝘨𝘪𝘵 𝘳𝘦𝘴𝘦𝘵 📘 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: You modified 𝘪𝘯𝘥𝘦𝘹.𝘩𝘵𝘮𝘭 and 𝘴𝘵𝘺𝘭𝘦.𝘤𝘴𝘴, then ran:   ⌨️ 𝘨𝘪𝘵 𝘢𝘥𝘥 . But you only wanted to add index.html. To fix that: Option 1️⃣ ⌨️ 𝘨𝘪𝘵 𝘳𝘦𝘴𝘵𝘰𝘳𝘦 --𝘴𝘵𝘢𝘨𝘦𝘥 𝘴𝘵𝘺𝘭𝘦.𝘤𝘴𝘴 Option 2️⃣ ⌨️ 𝘨𝘪𝘵 𝘳𝘦𝘴𝘦𝘵 𝘴𝘵𝘺𝘭𝘦.𝘤𝘴𝘴 Now 𝘴𝘵𝘺𝘭𝘦.𝘤𝘴𝘴 is unstaged but your edits are still there — safe and sound 💪 #Git #GitTips #DevTools #Coding #SoftwareDevelopment #VersionControl #WebDevelopment #DeveloperCommunity #Programming #TechTips

To view or add a comment, sign in

Explore content categories