# 𝗠𝗮𝘀𝘁𝗲𝗿𝗶𝗻𝗴 𝗚𝗶𝘁: 𝗨𝗻𝗱𝗲𝗿𝘀𝘁𝗮𝗻𝗱𝗶𝗻𝗴 𝘁𝗵𝗲 𝗧𝗵𝗿𝗲𝗲 𝗞𝗲𝘆 𝗔𝗿𝗲𝗮𝘀 𝗮𝗻𝗱 𝗛𝗼𝘄 𝘁𝗼 𝗨𝗻𝗱𝗼 𝗔𝗰𝗰𝗶𝗱𝗲𝗻𝘁𝗮𝗹 𝗖𝗼𝗺𝗺𝗶t

If you've ever accidentally committed sensitive files like `appsettings.json` to GitHub 😨 — you're not alone.

Today, I explored two crucial Git concepts:

✅ 𝗧𝗵𝗲 𝗧𝗵𝗿𝗲𝗲 𝗞𝗲𝘆 𝗔𝗿𝗲𝗮𝘀 𝗶𝗻 𝗚𝗶𝘁 (𝘄𝗶𝘁𝗵 𝘀𝗶𝗺𝗽𝗹𝗲 𝗲𝘅𝗮𝗺𝗽𝗹𝗲𝘀):

1. 𝗪𝗼𝗿𝗸𝗶𝗻𝗴 𝗗𝗶𝗿𝗲𝗰𝘁𝗼𝗿𝘆  
    This is where you write your code and make changes.  
    🛠 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: You edit `appsettings.json` or add a new feature in a `.cs` file.
    
2. 𝗦𝘁𝗮𝗴𝗶𝗻𝗴 𝗔𝗿𝗲𝗮 (𝗜𝗻𝗱𝗲𝘅)  
    This is a temporary area where you tell Git which changes you want to include in your next commit.  
    🛠 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: You run `git add appsettings.json`. Now Git is ready to commit it.
    
3. 𝗥𝗲𝗽𝗼𝘀𝗶𝘁𝗼𝗿𝘆 (𝗟𝗼𝗰𝗮𝗹 𝗥𝗲𝗽𝗼)  
    This is where your committed history is stored.  
    🛠 𝗘𝘅𝗮𝗺𝗽𝗹𝗲: You run `git commit -m "Added config"`. Now that file is permanently saved in your local repo (and possibly pushed to GitHub).
    

🔄 𝗛𝗼𝘄 𝘁𝗼 𝗨𝗻𝗱𝗼 𝗔𝗰𝗰𝗶𝗱𝗲𝗻𝘁𝗮𝗹 𝗖𝗼𝗺𝗺𝗶𝘁𝘀 (𝘄𝗶𝘁𝗵𝗼𝘂𝘁 𝗹𝗼𝘀𝗶𝗻𝗴 𝗹𝗼𝗰𝗮𝗹 𝘄𝗼𝗿𝗸)

Let’s say you accidentally committed a file like `appsettings.json` to GitHub. Here’s how to fix it:

1. Add the file to `.gitignore`: appsettings.json
    
2. Remove it from Git tracking (but keep it locally): git rm --cached appsettings.json
    
3. Commit the removal: git commit -m "Remove sensitive file from tracking"
    
4. Push the clean state: git push origin main --force
    

💡 𝗤𝘂𝗶𝗰𝗸 𝗧𝗶𝗽:  
Use `git reset --soft HEAD~1` to remove the last commit but keep your code changes safe locally.

𝗧𝗵𝗮𝗻𝗸𝘀 𝘁𝗼 𝘁𝗵𝗲 𝗤𝘂𝗶𝗰𝗸 𝗧𝗶𝗽, 𝗜 𝗱𝗲𝗹𝗲𝘁𝗲𝗱 𝗿𝗲𝗰𝗲𝗻𝘁 𝗰𝗼𝗺𝗺𝗶𝘁𝘀 𝘄𝗶𝘁𝗵 𝗲𝗮𝘀𝗲.

❓ 𝗛𝗮𝘃𝗲 𝘆𝗼𝘂 𝗲𝘃𝗲𝗿 𝗰𝗼𝗺𝗺𝗶𝘁𝘁𝗲𝗱 𝗮 𝘀𝗲𝗰𝗿𝗲𝘁 𝗼𝗿 𝗰𝗼𝗻𝗳𝗶𝗴 𝗳𝗶𝗹𝗲 𝗯𝘆 𝗺𝗶𝘀𝘁𝗮𝗸𝗲?  
𝗪𝗵𝗮𝘁’𝘀 𝘆𝗼𝘂𝗿 𝗴𝗼-𝘁𝗼 𝗺𝗲𝘁𝗵𝗼𝗱 𝘁𝗼 𝘂𝗻𝗱𝗼 𝗶𝘁 𝘄𝗶𝘁𝗵𝗼𝘂𝘁 𝗹𝗼𝘀𝗶𝗻𝗴 𝗽𝗿𝗼𝗴𝗿𝗲𝘀𝘀?
