🔁 Git Reset vs Git Revert — I Used to Think They Were the Same… Early on, I assumed both commands did one simple thing: “Undo changes” But while working on a project, I realized they solve completely different problems. And using the wrong one can break your workflow. 🔙 git reset (Rewrites History) - Moves the branch pointer backward - Can remove commits from history - Affects your local repository Use when: - Undoing local commits - Cleaning up commits before pushing Common Commands: - git reset --soft HEAD1 → Undo commit, keep changes staged - git reset --mixed HEAD1 → Undo commit, keep changes unstaged - git reset --hard HEAD~1 → Remove commit + delete changes Example: Fixing unclear commits before pushing ↩ git revert (Safe Undo) - Creates a new commit that reverses changes - Keeps history intact - Safe for shared repositories Use when: - Changes are already pushed - Working in a team environment Common Commands: - git revert HEAD → Revert last commit - git revert <commit-id> → Revert specific commit Example: Reverting a faulty production change 🎯 Takeaway: Never use reset on shared branches. Prefer revert when collaborating. #Git #GitHub #DevOps #VersionControl
Git Reset vs Git Revert: Choosing the Right Command
More Relevant Posts
-
Why does Git remain the undisputed standard for version control 20 years later? Key Points to Watch: -Distributed Power: Every developer has the entire history, eliminating the "server is down" bottleneck. -Integrity: The use of SHA-1 hashing ensures that what you commit is exactly what gets deployed. -Branching Efficiency: In Git, a branch is just a pointer to a commit, making "feature branching" nearly instant and zero-cost. The Engine of Distributed Truth Headline: Why Git is the "Mission Control" of Modern Engineering Before we had automated pipelines and cloud-native deployments, we had a massive problem: Collaboration at Scale. In 2005, the Linux kernel team faced a crisis that forced a total rethink of how we handle code. The result was Git—a tool built by Linus Torvalds in just two weeks that fundamentally changed how the world builds software. The "Architect" View on Git: -Zero Single Point of Failure: Unlike older centralized systems (SVN/CVS), Git is distributed. Every clone is a full backup. If the main server goes dark, the project lives on every engineer's machine. -Immutable History: Every commit is cryptographically hashed. In a DevOps pipeline, this is your "Chain of Custody"—you know exactly which lines of code triggered which deployment. -Branching as a Strategy: Git made branching "cheap." This allowed us to move away from "all hands on one file" to isolated feature development, which is the heartbeat of CI/CD. Whether I'm managing a complex GitHub Enterprise migration or spinning up a new microservice, Git isn't just a "save button." It is the source of truth that triggers the entire automation lifecycle. Quick Poll for the Devs: When you're in the terminal, are you a git rebase perfectionist or a git merge traditionalist? #Git #DevOps #VersionControl #OpenSource #SoftwareArchitecture #CloudEngineering #GitHub #TechHistory #7EagleGroup #7EagleAcademy Jordie Kern , Adam Peters, Brad Lawson, M.S., Donavan Maldonado-Fashina
To view or add a comment, sign in
-
-
🚀 GitLab Migration: A Story Between Old Repo & New Repo 😄 So I recently had to migrate projects from one GitLab to another… and honestly, it felt like shifting houses 🏠 🔹 Step 1: Packed everything git clone --mirror 👉 “Take EVERYTHING. Even things I forgot existed.” 🔹 Step 2: Moved to new place git push --mirror 👉 “Congrats, new GitLab… you now have my entire past.” 🔹 Step 3: Panic moment 😱 Error: “deny updating a hidden ref” 👉 Me: “WHAT DID I BREAK???” 👉 GitLab: “Relax… that’s just merge request stuff.” 🔹 Step 4: Trust issues 👉 Checked commits 👉 Checked branches 👉 Checked again… just in case 🔹 Step 5: Size mismatch 🤨 Old repo: 500 MB New repo: 480 MB 👉 Me: “WHERE ARE MY 20 MB???” 👉 Git: “Bro… I cleaned your mess.” 🔹 Reality check 💀 ❌ Members didn’t come ❌ Permissions didn’t come ❌ Pipelines didn’t come 👉 Basically moved house… but forgot the people 💡 Final lesson: If commits match → You’re safe If branches match → You’re happy If no errors → Don’t overthink 😄 #DevOps #GitLab #Migration #Git
To view or add a comment, sign in
-
Ever feel lost in the weeds of Git workflows? You're not alone! Keeping code organized can be a real challenge. I’ve been thinking about branching strategies lately, and wanted to share a quick rundown of a couple popular approaches. Gitflow is a robust option – think dedicated branches for features, releases, and hotfixes, all flowing into your main production code. It's great for larger projects with scheduled releases. But sometimes, simpler is better. GitHub Flow focuses on keeping your main branch *always* deployable. You branch for features, submit pull requests, and deploy directly from main. It’s a really streamlined process. And a quick tip that saves SO much headache: always, always use a .gitignore file! Seriously. Prevent accidental commits of build artifacts, dependencies (like node_modules!), environment files, and those pesky editor-specific files. Here’s a little example for Node.js projects: # Dependencies node_modules/ # Environment variables .env # Build output dist/ build/ # Logs logs/ *.log # Editor files .vscode/ .idea/ *.swp Finally, before merging *anything*, a solid code review is crucial. A quick checklist: style guidelines, tests, updated documentation, no commented-out code, proper error handling, and thinking about performance & security. What branching strategy does your team swear by, and what’s one thing you *always* include in your code review process? Let’s learn from each other!
To view or add a comment, sign in
-
-
🔧 Understanding git reset in a simple way (Senior Dev concept) One of the most important Git concepts every developer should clearly understand is how different git reset modes behave. Git has 3 key layers: Commit history (HEAD) Staging area (index) Working directory Here’s the breakdown 👇 🟢 git reset --soft Moves HEAD only Keeps staging area intact Keeps working directory unchanged 👉 Use case: When you want to redo commits but keep changes staged. 🟡 git reset --mixed (default) Moves HEAD Resets staging area Keeps working directory unchanged 👉 Use case: When you want to unstage files but keep your code. 🔴 git reset --hard Moves HEAD Resets staging area Resets working directory ⚠️ This deletes all changes permanently (use carefully) 💡 Simple memory trick: soft → keep everything mixed → unstage changes hard → erase everything Understanding this properly is critical in real-world development and interviews, especially at senior level. #Git #GitHub #SoftwareEngineering #WebDevelopment #DevOps #CodingTips
To view or add a comment, sign in
-
📌 Git Workflow and Commands Most engineers believe Git mastery is about memorizing a bunch of obscure commands 🤯. It's not — it's about understanding the right patterns and workflows to save your skin in a crisis. ``` Branch: main + develop + feature/* Commit: Conventional commits, GPG signed PR Flow: 2-reviewer gate, squash merge Rebase: Clean history, no merge noise Recovery: reset, reflog, cherry-pick Myth: Gitflow is the only way to manage branches 🌟. Reality: Trunk-based development can be just as effective, if not more, with the right commit and PR flow strategies in place 🚀. Senior engineers use Git differently — they focus on simplicity, clean history, and a solid understanding of recovery commands 💻. They know that a well-crafted commit message and a 2-reviewer gate can save hours of debugging time 🕒. 💬 What's your go-to Git strategy: 1️⃣ Branch 2️⃣ Commit 3️⃣ PR Flow 1️⃣ Branch 2️⃣ Commit 3️⃣ PR Flow Rebase mastery, or Recovery techniques? #GitMastery #DevTools #CodeQuality #VersionControl #SoftwareEngineering
To view or add a comment, sign in
-
-
🚀 𝟗𝟎 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐃𝐞𝐯𝐎𝐩𝐬 | 𝐋𝐞𝐚𝐫𝐧𝐢𝐧𝐠 𝐢𝐧 𝐏𝐮𝐛𝐥𝐢𝐜 | 𝐇𝐚𝐧𝐝𝐬-𝐎𝐧 | 𝐏𝐫𝐨𝐣𝐞𝐜𝐭𝐬 🌳 Branching out into Version Control: My First Git Repo! Day 22 of #90DaysOfDevOps is done! ✅ Today, I transitioned from scripting to mastering Git—the absolute backbone of DevOps and modern software engineering. 👨💻 I set up my global config, initialized my first repository, and got hands-on with the core workflow: Working Directory ➡️ git add (Staging) ➡️ git commit (Repository). ✅ git init → git add → git commit → Repeat! 💡 Biggest Aha! Moment: Understanding the Staging Area. It isn’t just an extra annoying step; it’s a drafting space that lets you group related changes together before sealing them into a commit, keeping the project history clean and logical! 🔗💻 GitHub Repo: https://lnkd.in/dZsmFiQT #90DaysOfDevOps #DevOpsKaJosh #TrainWithShubham #Git #GitHub #VersionControl #DevOpsJourney
To view or add a comment, sign in
-
Been looking into different Git branching strategies lately and figured I'd share a quick comparison. Git Flow is probably the most well-known. It uses multiple long-lived branches like develop and master, plus feature branches. Works great for scheduled releases but can feel heavy for smaller teams. GitHub Flow is simpler. Just one main branch and feature branches. You merge to main when ready. Pretty straightforward if you deploy often. Trunk-based development takes it further. Everyone commits to main frequently, sometimes multiple times a day. Requires good CI/CD and feature flags though. There's also GitLab Flow which sits somewhere in between, using environment branches. Honestly, the best one depends on your team size, release schedule, and how often you deploy. #GitWorkflow #SoftwareEngineering #DevOps
To view or add a comment, sign in
-
Still confused with Git commands? You’re not alone 👇 Most developers use Git daily… but only a few actually understand it properly. So I found this complete Git guide (PDF) that simplifies everything 👇 👉 Core Concepts: ✔️ Version Control & Collaboration ✔️ Branching & Merging ✔️ Tracking Changes 👉 Essential Commands: ✔️ git init, clone, add, commit ✔️ git push, pull, fetch ✔️ branch, merge, checkout 👉 Advanced Commands: ✔️ stash, cherry-pick, rebase ✔️ reset vs revert ✔️ bisect, reflog 👉 Pro Tips: ✔️ Clean commit history ✔️ Resolve merge conflicts ✔️ Use aliases & flags for efficiency 👉 Real-World Use Cases: ✔️ Team collaboration on projects ✔️ Handling hotfixes in production ✔️ Rolling back buggy releases ✔️ Feature development using branches 💡 Git is not just a tool — it’s a must-have skill for every developer. 📌 Save this post 🔁 Repost to help others 👨💻 Follow Abhishek Sharma for more such content #Git #GitHub #VersionControl #SoftwareEngineer #Developers #TechJobs #CodingInterview #LearnToCode #CareerGrowth
To view or add a comment, sign in
-
Wrote a short note on something I recently found useful while working with Git — git cherry-pick. It helped me move specific commits across branches without merging everything, especially in a GitFlow setup. Tried to keep it simple and practical. Read here: https://lnkd.in/dt4xQ7Da #git #devops #versioncontrol
To view or add a comment, sign in
-
🚀 DevOps Journey – Day 18 / 100 Today I learned real-time Git workflow with multiple developers + GitHub repo management 🔥 ⸻ 🔹 🧑💻 Real-Time Scenario 👨💻 Dev1 → Already developed code & pushed to GitHub 👨💻 Dev2 → New joiner (no code in local system) 👉 What should Dev2 do? ✔️ Clone the Repository • git clone <repo_url> → Entire code + history comes to local ⸻ 🔹 🔄 Clone vs Pull ✅ Clone • First time download • Full repo + all branches ✅ Pull • Get latest changes • Used after clone 💡 Pull = Fetch + Merge ⸻ 🔹 🌿 Branch & Sync • git branch -a → Show local + remote branches 👉 Workflow: 1. Make changes locally 2. git push → Send to GitHub 3. Other dev makes changes 4. git pull → Get updates ⸻ 🔹 🔍 Fetch vs Merge • git fetch origin branch → Check new commits (no merge) • git merge origin/branch → Merge changes into local ⸻ 🔹 ⚙️ GitHub Repository Settings 📌 You can manage repo using UI: • Rename repository • Change default branch • Change visibility (Public → Private) • Transfer ownership • Archive (read-only mode) • Delete repository (Danger Zone ⚠️) ⸻ 🔹 🆚 Git vs GitHub • Git → CLI tool (local system) • GitHub → Web UI (remote repo hosting) ⸻ 💡 Pro Tip: Every developer should know this flow: 👉 Clone → Work → Push → Pull → Repeat This is how real companies work 🚀 #DevOps #Git #GitHub #Linux #VersionControl #100DaysOfDevOps #LearningJourney #Cloud #Automation #RealTime #frontlinemedia #flm #DevSecOps #MultiCloud
To view or add a comment, sign in
-
Explore related topics
Explore content categories
- Career
- Productivity
- Finance
- Soft Skills & Emotional Intelligence
- Project Management
- Education
- Technology
- Leadership
- Ecommerce
- User Experience
- Recruitment & HR
- Customer Experience
- Real Estate
- Marketing
- Sales
- Retail & Merchandising
- Science
- Supply Chain Management
- Future Of Work
- Consulting
- Writing
- Economics
- Artificial Intelligence
- Employee Experience
- Workplace Trends
- Fundraising
- Networking
- Corporate Social Responsibility
- Negotiation
- Communication
- Engineering
- Hospitality & Tourism
- Business Strategy
- Change Management
- Organizational Culture
- Design
- Innovation
- Event Planning
- Training & Development