Git commands I actually use in real projects ( Part 2 ) : When we work in real projects, Git is not just git add and git push. We often mess up commits, need to sync with remote, or clean things properly. These are some Git commands I use regularly and why. Many times there is a situation where I completely mess things up and want to go back exactly like a previous commit. In that case I use: git reset --hard <commit-id> This removes both commit and code changes. I use this only when I am very sure. Sometimes a file is already tracked and pushed, but later I realize it should not be part of Git, like secrets or config files. Then I use: git rm --cached <file-name> This removes the file from Git tracking but keeps the file locally. When I create a new branch locally and want Git to know this branch exists in remote, I use: git push -u origin bugfixes This pushes the local branch and sets upstream, so next time I can just do git push. To move between branches, I use: git checkout main To delete a local branch after cleanup or merge: git branch -d dev Some basic commands I run daily before doing anything risky: git status git log --oneline --graph These commands help me understand where I am and what is happening in the repo. Once you understand these Git basics, working in real projects becomes much easier. ( image generated using chatgpt for better visualization ) Follow me for more devops and SRE content. #git #github #VCS #versioncontrol #reset #gitreset #auditing #rm #buildinpublic #learning #selfgrowth #authorization
Git Commands for Real Projects: Reset, Remove, and More
More Relevant Posts
-
🚀 Day 131 of Daily Git Commands Advanced Git hooks configuration for professional development workflows! Today we're diving into setting up custom hooks with environment integration. git config core.hooksPath ./hooks && export GIT_AUTHOR_EMAIL GIT_COMMITTER_EMAIL && chmod +x hooks/pre-receive This powerful combination configures a custom hooks directory, sets up environment variables for author tracking, and makes your pre-receive hook executable. Perfect for teams implementing quality gates and automated integration testing! 💡 Pro Tip: Remember this as "Hook Path Export Chmod" - HPE! Think of it as setting up your Hook Production Environment in three steps: configure path, export variables, make executable. 🎯 Use Cases: Beginner Level: Setting up basic validation hooks for your first team project to ensure code quality standards before commits are accepted. Seasoned Professional #1: Implementing complex CI/CD integration where hooks trigger Docker builds, run test suites across multiple environments, and validate security compliance before allowing pushes to production branches. Seasoned Professional #2: Creating sophisticated branch protection workflows where pre-receive hooks communicate with external APIs, validate JIRA tickets, enforce code review requirements, and log detailed audit trails for enterprise compliance. The beauty of custom hooks lies in their flexibility - they transform Git from a version control system into a comprehensive development workflow orchestrator! 🔧 What's your most creative use of Git hooks? Share below! 👇 #Git #DevOps #SoftwareDevelopment #CI #CD #QualityAssurance #TeamLeadership #TechTips My YT channel Link: https://lnkd.in/d99x27ve
To view or add a comment, sign in
-
Git part 3 # GIT Push & Pull 🔹 Push Push sends your local commits to the remote repository (GitHub/GitLab/Bitbucket) Makes your changes visible to the entire team Used after: Completing a feature Fixing a bug Updating pipeline scripts Real-time example You updated a Jenkinsfile locally After testing → you push the commit so the CI pipeline can run 🔹 Pull Pull fetches latest changes from remote and merges into your local branch Keeps your code up to date Prevents conflicts before starting work Important Rule: Always pull before push Avoids merge conflicts #Merge Conflicts A merge conflict happens when Git can’t decide which change to keep Occurs when: Same file Same line Changed differently by multiple people # .gitignore .gitignore tells Git what NOT to track Prevents: Large files Sensitive data Unnecessary noise Common ignored items Logs Build outputs Environment files IDE configs # Tags Tags mark important points in Git history Commonly used for releases 🔹 Lightweight Tag Simple pointer to a commit No metadata 🔹 Annotated Tag Contains: Message Author Date example v1.0-prod → first production release v2.2-hotfix → urgent patch #Cherry-pick Cherry-pick applies one specific commit to another branch Does NOT merge entire branch example A hotfix commit exists in develop Production needs only that fix Cherry-pick that commit into release Can cause duplicate commits if misused Rebase Rebase moves commits onto a new base Makes history linear Rewrites commit history example Feature branch is behind develop Rebase it to include latest changes Important Rule - - >Never rebase shared branches - - >Rebase only local branches #Stash Stash temporarily stores uncommitted changes Useful when you need to: Switch branches Handle urgent issues example You’re working on a feature Production issue comes up #GitHub #Git #DevOps #DevSecOps Git part 4 continues....
To view or add a comment, sign in
-
-
🚀 Mastering Git & GitHub: The Backbone of Modern Engineering Workflows Git is not just a version control tool — it’s a distributed system for collaboration, traceability, and reliability. 🔹 Core Git Architecture Working Directory → Where code changes happen Staging Area (Index) → Controlled snapshot before commit Local Repository → Immutable history (commits) Remote Repository (GitHub) → Collaboration & CI/CD integration 🔹 Essential Git Operations git add → Moves changes to staging (index control) git commit → Creates a cryptographic snapshot (SHA-based) git push → Syncs local history with remote git fetch → Updates remote refs (no merge risk) git pull --rebase → Clean linear history (preferred in teams) 🔹 Branching Strategy (Real-World Use) Feature isolation using lightweight branches Safe parallel development Fast-forward & recursive merges Tags for release versioning (git tag v1.0.0) 🔹 Why Git Matters in Production ✔ Auditability (who, what, when, why) ✔ Rollback & recovery (git reset, git revert) ✔ CI/CD automation trigger point ✔ Infrastructure as Code (Terraform, Helm, YAML pipelines) 📌 Pro Tip: Use git fetch + rebase instead of blind pulls to avoid merge chaos in enterprise repositories. Git discipline = clean history + stable releases + confident deployments 💡 #Git #GitHub #DevOps #CloudEngineering #QAEngineering #CICD #VersionControl #SoftwareEngineering #InfrastructureAsCode
To view or add a comment, sign in
-
-
Stop treating Git like a "Save Button." It is your safety net. 🕸️ I see too many "Senior" Engineers who still only know three commands: git add, git commit, git push. If this is your entire workflow, you aren't doing DevOps. You are just storing code. In a real production environment, Git is the difference between a smooth release and a 3 AM fire drill. At Cloud Train, we teach that "Git for DevOps" is a completely different skill set than "Git for Developers." The 4 Essentials you must master in 2026: 1️⃣ The Strategy (Branching): Are you using GitFlow or Trunk-Based Development? If you don't know the difference, you are slowing down your entire team. 2️⃣ The Gatekeeper (Pull Requests): A PR isn't just for code review. It’s for automated testing. If your CI pipeline doesn't trigger on a PR, you are flying blind. 3️⃣ The History (Rebase vs. Merge): A messy commit history makes debugging impossible. Learn to squash. Learn to rebase. Keep your history clean. 4️⃣ The Emergency (Revert vs. Reset): When Production breaks (and it will), do you know exactly how to roll back without losing data? The Truth: Code is easy to write. Reliable code requires a reliable workflow. Don't let "Git Confusion" be the bottleneck in your pipeline this year. I’m curious about the debate: Team "Merge" or Team "Rebase"? Which one does your company force you to use? 👇 Let the battle begin in the comments! #CloudTrain#Git #DevOps #VersionControl #SoftwareEngineering #CloudTrain #Workflow #CodingBestPractices #TechSkills
To view or add a comment, sign in
-
-
🚀 Post #352 — Git beyond commit & push Most developers use Git. From developer to Engineer Very few actually understand it. This week I went deeper into Git — the commands that save you during production bugs, bad merges, and broken releases. Here’s a one-liner cheat sheet for senior folks 👇 🧠 Advanced Git commands (real-world meaning) 🔄 git rebase → Rewrite commit history to keep branches clean and linear 🎯 git cherry-pick → Apply a specific commit from another branch (no full merge) 🕵️ git reflog → Recover lost commits even after reset or rebase ⏪ git reset → Move HEAD to a previous state (soft/mixed/hard matters) 🧾 git blame → Identify who changed a line and why 🧪 git bisect → Binary search to find the commit that introduced a bug 📜 git log → Inspect commit history (filters = power) 🚫 git revert → Safely undo changes by creating a new commit 🏷️ git tag → Mark release points (v1.0.0, prod-ready, hotfix) 💡 Why this matters in real jobs Debugging production issues Handling messy merge conflicts Backporting fixes Writing clean, reviewable history Working confidently on large teams Knowing Git deeply ≠ memorizing commands. It’s about control, recovery, and confidence. 👀 Next, I’m planning to deep-dive into rebase vs merge in real production workflows. #Git #SoftwareEngineering #BackendEngineering #DevOps #EngineeringGrowth
To view or add a comment, sign in
-
-
𝐆𝐢𝐭 𝐂𝐨𝐦𝐦𝐚𝐧𝐝𝐬 𝐄𝐯𝐞𝐫𝐲 𝐄𝐧𝐠𝐢𝐧𝐞𝐞𝐫 𝐒𝐡𝐨𝐮𝐥𝐝 𝐊𝐧𝐨𝐰 🚀 People rush into CI/CD, Docker, Kubernetes… but struggle with Git basics. If you want to work confidently in any tech team, Git is non-negotiable. Here’s a clean, practical Git cheat-sheet every developer & DevOps engineer should know 👇 ✔ 𝐠𝐢𝐭 𝐢𝐧𝐢𝐭 → Create an empty Git repository or reinitialize an existing one ✔ 𝐠𝐢𝐭 𝐬𝐭𝐚𝐭𝐮𝐬 → Show the working tree status ✔ 𝐠𝐢𝐭 --𝐯𝐞𝐫𝐬𝐢𝐨𝐧 → Check the Git version ✔ 𝐠𝐢𝐭 𝐚𝐝𝐝 . → Add files to the staging area ✔ 𝐠𝐢𝐭 𝐜𝐨𝐦𝐦𝐢𝐭 -𝐦 "𝐦𝐞𝐬𝐬𝐚𝐠𝐞" → Save your changes to the local repository ✔ 𝐠𝐢𝐭 𝐥𝐨𝐠 → See commit history ✔ 𝐠𝐢𝐭 𝐝𝐢𝐟𝐟 → Check what has changed before committing ✔ 𝐠𝐢𝐭 𝐩𝐮𝐬𝐡 → Send your changes to the remote repository ✔ 𝐠𝐢𝐭 𝐜𝐨𝐧𝐟𝐢𝐠 --𝐠𝐥𝐨𝐛𝐚𝐥 𝐮𝐬𝐞𝐫.𝐧𝐚𝐦𝐞 "𝐘𝐨𝐮𝐫 𝐍𝐚𝐦𝐞" → Sets the global username. ✔ 𝐠𝐢𝐭 𝐜𝐨𝐧𝐟𝐢𝐠 --𝐠𝐥𝐨𝐛𝐚𝐥 𝐮𝐬𝐞𝐫.𝐞𝐦𝐚𝐢𝐥 "𝐲𝐨𝐮𝐫𝐞𝐦𝐚𝐢𝐥@𝐞𝐱𝐚𝐦𝐩𝐥𝐞.𝐜𝐨𝐦"→ Sets the global email. ✔ 𝐠𝐢𝐭 𝐜𝐥𝐨𝐧𝐞 <𝐫𝐞𝐩𝐨𝐬𝐢𝐭𝐨𝐫𝐲_𝐮𝐫𝐥> → Creates a copy of a remote repository on your local machine. ✔ 𝐠𝐢𝐭 𝐜𝐥𝐞𝐚𝐧 -𝐧 → Shows a list of untracked files that will be removed. ✔ 𝐠𝐢𝐭 𝐜𝐥𝐞𝐚𝐧 -𝐟 → Removes untracked files from the working directory. ✔ 𝐠𝐢𝐭 𝐛𝐫𝐚𝐧𝐜𝐡 → List all local branches ✔ 𝐠𝐢𝐭 𝐛𝐫𝐚𝐧𝐜𝐡 𝐛𝐫𝐚𝐧𝐜𝐡-𝐧𝐚𝐦𝐞 → Create a new branch ✔ 𝐠𝐢𝐭 𝐜𝐡𝐞𝐜𝐤𝐨𝐮𝐭 𝐛𝐫𝐚𝐧𝐜𝐡-𝐧𝐚𝐦𝐞 → switches to another branch ✔ 𝐠𝐢𝐭 𝐜𝐡𝐞𝐜𝐤𝐨𝐮𝐭 -𝐛 𝐛𝐫𝐚𝐧𝐜𝐡-𝐧𝐚𝐦𝐞 → creates a branch and switches to it ✔ 𝐠𝐢𝐭 𝐦𝐞𝐫𝐠𝐞 𝐛𝐫𝐚𝐧𝐜𝐡-𝐧𝐚𝐦𝐞 → merges another branch into the current/master branch ✔ 𝐠𝐢𝐭 𝐛𝐫𝐚𝐧𝐜𝐡 -𝐝 𝐛𝐫𝐚𝐧𝐜𝐡-𝐧𝐚𝐦𝐞 → deletes a branch after the work is done ✔ 𝐠𝐢𝐭 𝐫𝐞𝐬𝐞𝐭 → Used when you want to undo local changes. ✔ 𝐠𝐢𝐭 𝐫𝐞𝐯𝐞𝐫𝐭 → Safely undo a commit ✔ 𝐠𝐢𝐭 𝐬𝐭𝐚𝐬𝐡 → Temporarily save work when you’re not ready to commit If you’re learning DevOps or working as a developer master Git before chasing advanced tools. #git #DevOps #CloudComputing #LearningInPublic #TechSkills #Beginners #ITCareer #Practice
To view or add a comment, sign in
-
#Day2Git #part2 Stashing: save work temporarily -> stash saves unfinished changes like pausing a game and resuming later. its hide you mods so you cand switch branches clean. cmd: git stash (save), git stash apply (restore), git stash list (see saved), git stash drop (delete) exp-> mid feature, urgent bug: git stash - switch to bug branch, fix, switch back, git stash pop with quick context switch during on-call without committing junk Other Advanced Commands (Quick Hits) git bisect: Binary search for bug intro commit. Example: git bisect start; git bisect bad; git bisect good – finds culprit. git reflog: Recover lost commits. Example: git reflog – see history, reset to old HEAD. git submodule: Manage nested repos. Example: Add external lib – git submodule add url. DevOps Pro: git hook scripts (pre-commit checks) – automate linting before pushes. now this is fulfilled your Git fundamental's and advanced topic then, our next topic is Containerization using Docker #DevOps #GitBasics #ZeroToHero #GitAdvanced #VersionControl #Git
To view or add a comment, sign in
-
🚀 Master the Git Workflow: A Quick Guide Whether you're a seasoned dev or just starting, these 20 commands are your bread and butter. Here is the simple breakdown: 🛠️ The Basics git init: 🆕 Create a brand new local repository. git config: 👤 Set your identity (name & email). git clone: 👯 Copy an existing remote project to your machine. git remote: 🔗 Manage connections to external repositories. 📝 Daily Development git status: 👀 See what files you've changed or staged. git add: 📥 Move changes to the "staging area" (prepare for save). git commit: 💾 Save your staged changes to project history. git push: 📤 Upload your local saves to the cloud (GitHub/GitLab). 🔄 Staying Updated git pull: 📥 Download and merge updates from teammates. git fetch: 🔍 See what’s new on the remote without merging yet. git branch: 🌿 Create or list different versions of the project. git checkout: 🏃♂️ Jump between different branches. 🔀 Merging & Cleaning git merge: 🤝 Combine work from two different branches. git rebase: 🪜 Move your commits to a new starting point for a cleaner history. git log: 📖 View the "timeline" of every save ever made. git diff: 📋 Compare exactly what lines of code changed. 🆘 The "Oops" & Advanced Tools git stash: 📦 Temporarily hide messy work to fix a quick bug elsewhere. git reset: ⏪ Unstage files or undo commits entirely. git revert: 🛡️ Create a "counter-commit" to undo a past mistake safely. git cherry-pick: 🍒 Grab one specific commit from another branch and apply it here. Which Git command do you use most often? Let me know in the comments! 👇 #SoftwareDevelopment #CodingTips #Git #Programming #WebDev #TechCommunity
To view or add a comment, sign in
-
-
Just wanted to share this I keep reminding myself of these Git commands again and again, so I thought I’d put them in one place. Might be handy for you too. You don’t need to know every Git command. But if you master the essentials, you can get out of almost any situation. Here are 22 Git commands every engineer should be comfortable with 👇 𝗕𝗮𝘀𝗶𝗰 𝗢𝗽𝗲𝗿𝗮𝘁𝗶𝗼𝗻𝘀 • git init – start a new repo • git clone – copy an existing repo • git status – check what’s going on • git log – view commit history 𝗪𝗼𝗿𝗸𝗶𝗻𝗴 𝘄𝗶𝘁𝗵 𝗕𝗿𝗮𝗻𝗰𝗵𝗲𝘀 • git branch – create/list branches • git checkout / git switch – move between branches • git merge – merge changes safely 𝗦𝘁𝗮𝗴𝗶𝗻𝗴 & 𝗖𝗼𝗺𝗺𝗶𝘁𝘁𝗶𝗻𝗴 • git add – stage changes • git commit – save progress • git stash – temporarily park work • git reset – undo mistakes 𝗧𝗲𝗮𝗺 𝗖𝗼𝗹𝗹𝗮𝗯𝗼𝗿𝗮𝘁𝗶𝗼𝗻 • git push – send changes • git pull – sync updates • git remote – manage remotes • git tag – mark important versions 𝗔𝗱𝘃𝗮𝗻𝗰𝗲𝗱 (𝗯𝘂𝘁 𝘀𝘂𝗽𝗲𝗿 𝘂𝘀𝗲𝗳𝘂𝗹) • git diff – see what changed • git blame – track code ownership • git bisect – find bugs faster These are the commands I rely on most while working with teams and managing real projects. If you want a clear explanation of Git vs GitHub, this post by Madhan Vadlamudi worth checking out 👇 https://lnkd.in/eTAvsz_4 Hope this helps someone today Feel free to save it or add your go-to Git command in the comments. #git #developer #programming #softwareengineering #machinelearning #ai
To view or add a comment, sign in
-
🚀 12 Git Commands Every Developer Must Know 🔧 Git becomes really simple once you understand the right commands at the right time. Whether you’re a beginner, DevOps engineer, or working professional, these 12 Git commands cover 90% of daily Git usage 👇 🔹 git init – Initialize a new repository 🔹 git add – Stage your changes 🔹 git commit – Save changes with a message 🔹 git status – Check repo & file status 🔹 git branch – Manage branches 🔹 git checkout – Switch between branches 🔹 git merge – Merge branches 🔹 git pull – Fetch + merge remote changes 🔹 git push – Push local commits to remote 🔹 git fetch – Download changes without merging 🔹 git remote – Manage remote repositories 🔹 git reset – Undo commits safely (use carefully ⚠️) 💡 Pro Tip: If you master these commands, you’ll feel confident working with GitHub, GitLab, Bitbucket, and CI/CD pipelines. 📌 Save this post for revision 📌 Share with your team 📌 Comment “GIT” if you want an advanced Git cheatsheet #Git #GitCommands #DevOps #SoftwareDevelopment #Programming #Developer #Learning #VersionControl #Engineering
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