"Git Week 2: Ignoring, Viewing, Reverting Changes"

💻 - Git Week 2 Day 3 – Ignoring, Viewing & Reverting Changes Today I learned how to manage what Git tracks, view what’s changed, and fix mistakes if something goes wrong. These commands are essential for keeping repositories clean and organised — especially when working in teams or deploying to production. ⸻ 🚫 Ignoring Files with .gitignore Not every file in a project needs to be tracked — things like logs, temporary files, and environment variables should be ignored. You can create a .gitignore file to tell Git which files to skip: Example: echo "*.log" > .gitignore This command creates a .gitignore file and ignores all files ending with .log. You can edit this file manually or create it directly on GitHub before pushing your repository. 🔍 Viewing Changes with git diff Before committing, you can see exactly what’s changed since your last save point: git diff This shows all modified lines that haven’t been staged yet — helpful for reviewing before committing. You can also compare two commits or branches, for example: git diff master This compares your current branch against the master branch. 🧹 Unstaging Files with git restore If you’ve added something by mistake with git add, you can unstage it before committing: git restore --staged file This removes the file from the staging area but keeps your changes safe in the working directory. ⸻ Learning how to ignore, review, and revert changes gave me a much clearer understanding of how Git tracks progress — and how to stay in control of my repository history. ⸻ Next Up: I’ll be diving into remote repositories — learning how to connect local work to GitHub using commands like git remote add, git push, and git pull. If you’re following my DevOps journey, stay tuned for how I connect my local projects to the cloud 🌐 #Git #DevOpsJourney #VersionControl #GitHub #CloudComputing #LearningInPublic

  • No alternative text description for this image

To view or add a comment, sign in

Explore content categories