Git Reset and HTTPS vs SSH: DevOps Lessons Learned

Day 13 of my DevOps Journey. I broke a commit today. On purpose. And it fixed everything.🔥 Today I learned Git Reset and how to securely connect your server to GitHub - HTTPS vs SSH. First - The Real-World Problem that taught me Git Reset: Two developers. One repo. Dev1 had commits C1→C5. Dev2 added C6. Dev1 didn't pull C6 and made C7. Now Dev1 tries to push — ERROR. Why? Git expects order: C1, C2, C3, C4, C5, C6, C7. But Dev1 has C7 with no C6. The history is broken. The fix? Delete the commit, but keep the data. The command is "git reset --soft HEAD~1" C7 commit disappears. The work stays. Now pull C6 from Dev2. Recommit C7. Push succeeds.✅ Second — HTTPS vs SSH: Two ways to connect server to GitHub HTTPS → needs a token every time SSH → generate once, push forever HTTPS Token steps (short version): Profile → Settings → Developer Settings → Personal Access Tokens → Tokens (Classic) → Generate → select repo scope → copy to Notepad SSH Key steps: · ssh-keygen → press Enter 3 times · cd ~/.ssh then ll → you'll see two files · id_rsa = private key (stays on server) · id_rsa.pub = public key (goes to GitHub) · cat id_rsa.pub → copy the output · GitHub → Settings → SSH Keys → paste → done · Now push without credentials. Ever again. 🔑 —————————————— See you on Day 14 #DevOps #Git #GitHub #SSH #100DaysOfDevOps #Day13

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories