🧠 Protecting Your Main/Master Branch — The Unsung Hero of a Healthy Git Workflow 🚀 Imagine pushing untested code directly to production. Or worse — accidentally deleting your main branch. 😱 That’s why branch protection is one of the most crucial (but often ignored) DevOps practices for maintaining code quality and team safety. 🔍 What Is Branch Protection? Branch protection is a set of rules and restrictions applied to critical branches like main or master in Git repositories (GitHub, GitLab, Bitbucket, etc.). 🏗️ Why It’s Important Without protection, anyone can: Force push changes and overwrite others’ commits Merge without reviews or testing Delete the main branch accidentally These lead to: ❌ Broken builds ❌ Lost commits ❌ Security risks ❌ Time wasted on rollback or debugging ⚙️ How to Protect Your Main/Master Branch (GitHub Example) You can enable this in GitHub → Settings → Branches → Add Rule ✅ Recommended settings: Require pull request reviews before merging Require status checks to pass (build/test must succeed) Require linear history (no messy merges) Disallow force pushes Disallow deletions Optional (but smart): Enforce signed commits Restrict who can push directly Require approvals from code owners 🧩 Example: Production-Safe Git Workflow main # Protected – production-ready code develop # Active dev branch for features feature/* # Feature-specific branches hotfix/* # Urgent bug fixes Flow: 1️⃣ Developer creates a feature branch 2️⃣ Pushes code and raises a PR 3️⃣ Code review + CI pipeline runs 4️⃣ Merge only after approval and tests pass 5️⃣ Main stays clean, tested, and deployable 🧠 Best Practices ✅ Protect main and develop branches ✅ Always merge via Pull Requests (never direct commits) ✅ Require at least one reviewer approval ✅ Run automated tests (CI) before merging ✅ Use branch naming conventions (feature/login, fix/api-timeout) ✅ Review branch protection rules regularly 💡 Pro Tips 💥 Add “CODEOWNERS” file for automatic reviewer assignment 💥 Combine protection rules with GitHub Actions or Jenkins pipelines 💥 Automate security scans before merging 💥 Use status checks to block PRs with failing tests 💥 Communicate branch policies clearly in README 🧠 Real-World Tip In production environments, large teams (like Netflix, Microsoft, or Amazon) treat main as “sacred code.” Every single change goes through: Peer review Automated build validation Security scan That’s how they prevent downtime or data breaches from small mistakes. “Protecting your main branch isn’t about blocking developers — it’s about protecting production and empowering quality delivery.” 🔐 🧠 Read more: https://lnkd.in/gSgb_jga #Git #GitHub #DevOps #CI/CD #BestPractices #SoftwareDevelopment #CodeReview #GitTips #EngineeringExcellence
How to Protect Your Main Branch with Git
More Relevant Posts
-
“Everything as Code” Still Needs a Brain - Not Just a Git Repo —𝘮𝘺 𝘱𝘦𝘳𝘴𝘰𝘯𝘢𝘭 𝘷𝘪𝘦𝘸; 𝘰𝘱𝘪𝘯𝘪𝘰𝘯𝘴 𝘢𝘳𝘦 𝘮𝘺 𝘰𝘸𝘯. This week I read a post from my colleague Markus Rettstatt that lit up the comments. He was defending an “everything as code” mindset: • requirements as code • architecture as code • infrastructure as code • tests as code All living in a Git repository, versioned, reviewed, automated. And I agree with the core idea. But many people read it as: “So we don’t need requirements anymore.” “We don’t need architecture.” “We can throw away all the tools from the last 20 years.” That’s not what he said. And it’s not how I read it. In engineering, we still need the trio: • Requirements → the WHY • Architecture → the HOW • Source code → the WHAT “Everything as code” is not “forget the why and the how.” It’s “let the why, how, and what live closer together.” You can write a requirement in DOORS, in Polarion, in a Word file, in a Markdown file inside Git. You can draw an architecture in a modeling tool or describe it in a structured, versioned document next to the code. The form can change. The responsibility cannot. Another point that worried me in the comments: some people implied that “everything as code” would not fit standards like: • ASPICE • ISO 26262 • DO-178 From my experience (automotive, aerospace, energy, consumer electronics): these standards don’t care if your requirement is in a fancy enterprise tool or in a text file in Git. They care about: • traceability (requirement → architecture → code → test) • consistency • evidence that you followed a controlled process “Everything as code” can support all of that— sometimes even better, because you enable: • code review on requirements and architecture • automation for checks and traceability • shorter feedback loops You may have more work or less work depending on the tools you choose. If a tool becomes a bottleneck to speed, learning, or collaboration… then yes, it’s a good candidate to be replaced. But replacing a tool is very different from abandoning engineering discipline. So my view is simple: I’m for “everything as code” → when it helps us keep the WHY, the HOW and the WHAT aligned → and still respects the processes and evidence that ASPICE, ISO 26262, DO-178, etc. expect. Tools are negotiable. Good engineering is not. I’m curious: how far have you gone with “everything as code” in your teams—without losing traceability and rigor? #SoftwareEngineering #AutomotiveSoftware #EverythingAsCode #SoftwareArchitecture #ModernEngineeringPractices
To view or add a comment, sign in
-
-
New workflows for #SCM, or how to simplify DevX for tiny teams, and projects where the ratio of gitninja < gitphobic is skewed heavily towards people who really will never ever learn git. Call it skills deficiency, call it getting away with thumb drives and using web interfaces to upload files into github, it is akin to not learning to read as a developer. Not making a value judgement, but I have discovered a lot of devs over the years who have figured out how to not ever learn git, and secretly (or openly) refuse avoid using source control. There are a number of techniques I've seen to avoid using a git workflow: - use a thumb drive and hand the code to a coworker who will do the merge - start a merge or commit or push (usually some combo of this ... the commands were written down but never really understood so this gets dangerous fast) and call me (or someone) over to help when stuck - don't push code. Tell the boss bleep you. Excuse yourself for the day as you aren't in a good mood. I've seen this. - use unprotected main, and push using destructive techniques (seen this) - email the code to people (dangerous as you don't always get the right person in "outlook") - maintain a huge gigantic history at the header of the code, usually all in one file (never mind, git and any SCM will graciously maintain history) - uses a cheatsheet or notebook of commands, or an LLM to figure out what to do (see my last post) - never branch The list goes on. What is the answer to this? I agree the number of things you need to know as a person who works with an engineering team just to use git effectively is large, and vast. Brilliant people struggle with hit. So I will write this down: - In some cases you don't need git. But you need history. You need security of not losing work. Let this person use the SCM (Subversion/CVS) they remember. A good RE/DevOps person can mirror the repo to git. - Use a gatekeeper: In most companies now, there is a gatekeeper now. You can't simply push code. So quit torturing this person, but set up rules for how often and how code gets delivered - Or: I'm going to try out new SCMs that have the good features of git (namely distributed, low cost branching/forking) and leave out the features that most people don't need. The goal is not to create an elite force of people who all have the same skills. You need the designer. You need the EE. You need that i18n specialist. You need that marketing person (nah ... just kidding). So one goal for this coming year is to get familiar with other SCMs so I can quickly train up team members who are gitphobics and in situations where we can get by with a more simplified model of dev, something like Fossil SCM will work just great. You add files. You commit, and and wait, it already sync'd? No extra stuff. Nope. (credit: AI slop by Bing Image Creator using a prompt from human brain to make the perfect image DALL-3 or something. Writing by human intelligence slop).
To view or add a comment, sign in
-
-
⚙️ Git Workflow 1️⃣ Initialize Git git init Creates a hidden .git folder to track changes. Check it using: ls -la 2️⃣ Check Repo Status git status Shows if files are tracked, untracked, or committed. 3️⃣ Add Files git add filename Adds files to the staging area for tracking. Add all files: git add . 4️⃣ Commit Changes git commit -m "Added new feature" Saves a checkpoint with your message. 5️⃣ View Changes git diff # Show modifications git log # Show commit history 6️⃣ Undo or Go Back git reset --hard <commit-id> Goes back to a specific commit version. 🚀 Push Code to GitHub Steps: Create a GitHub account. Create a new repository. Connect local repo to GitHub: git remote add origin <repo_URL> Push your code: git push -u origin main 🔄 Pull and Fetch git pull Fetch and merge latest changes from remote git fetch Fetch updates but don’t merge automatically Use pull to get updates + merge. Use fetch when you just want to see new updates before merging. ⚙️ .gitignore File .gitignore tells Git which files to ignore while tracking. 🌿 Git Branching Strategy Why Use Branches? To work on new features or bug fixes without breaking main code. Makes teamwork smoother and organized. Common Branch Types Main / Master Branch: Always stable and production-ready. Feature Branch: Used to develop new features. Release Branch: Used for preparing code for deployment. Hotfix Branch: Used for urgent fixes in production. 🔄 Branch Commands git branch # List all branches git checkout -b feature1 # Create and switch to new branch git checkout main # Switch back to main branch git merge feature1 # Merge feature branch into main 🔁 Merge, Rebase, and Cherry-Pick 🔸 Merge Combines code from one branch into another. Keeps all commit history. 🔸 Rebase Rewrites commits in a straight line (clean history). Commonly used in professional DevOps workflows. 🔸 Cherry-Pick Pick a specific commit from one branch to another: git cherry-pick <commit-id> 👥 Pull Requests (PR) Used on GitHub when one branch wants to merge into another. Allows code review and approval before merging. Ensures quality and teamwork. 🧩 Example Git Workflow in Real Projects Developer creates a feature branch → works on code. Runs tests and commits changes. Pushes the branch to GitHub. Opens a Pull Request (PR) for review. Once approved → merged into main branch → deployed. Done😎 😎 #GitGithub #Devops
To view or add a comment, sign in
-
✅ *Git & GitHub Interview Questions & Answers* 🧑💻🌐 *1️⃣ What is Git?* *A:* Git is a distributed version control system to track changes in source code during development. *2️⃣ What is GitHub?* *A:* GitHub is a cloud-based platform that hosts Git repositories and supports collaboration, issue tracking, and CI/CD. *3️⃣ Git vs GitHub* - *Git:* Version control tool (local) - *GitHub:* Hosting service for Git repositories (cloud-based) *4️⃣ What is a Repository (Repo)?* *A:* A storage space where your project’s files and history are saved. *5️⃣ Common Git Commands:* - `git init` → Initialize a repo - `git clone` → Copy a repo - `git add` → Stage changes - `git commit` → Save changes - `git push` → Upload to remote - `git pull` → Fetch and merge from remote - `git status` → Check current state - `git log` → View commit history *6️⃣ What is a Commit?* *A:* A snapshot of your changes. Each commit has a unique ID (hash) and message. *7️⃣ What is a Branch?* *A:* A separate line of development. The default branch is usually `main` or `master`. *8️⃣ What is Merging?* *A:* Combining changes from one branch into another. *9️⃣ What is a Pull Request (PR)?* *A:* A GitHub feature to propose changes, request reviews, and merge code into the main branch. *🔟 What is Forking?* *A:* Creating a personal copy of someone else’s repo to make changes independently. *1️⃣1️⃣ What is .gitignore?* *A:* A file that tells Git which files/folders to ignore (e.g., logs, temp files, env variables). *1️⃣2️⃣ What is Staging Area?* *A:* A space where changes are held before committing. *1️⃣3️⃣ Difference between Merge and Rebase* - *Merge:* Keeps all history, creates a merge commit - *Rebase:* Rewrites history, makes it linear *1️⃣4️⃣ What is Git Workflow?* *A:* A set of rules like Git Flow, GitHub Flow, etc., for how teams manage branches and releases. *1️⃣5️⃣ How to Resolve Merge Conflicts?* *A:* Manually edit the conflicted files, mark resolved, then commit the changes.
To view or add a comment, sign in
-
🚀 Master Git Like a Pro: Essential Commands Every Developer Should Know! Whether you're just starting your coding journey or working on production-grade systems, this Git cheat sheet covers the most important commands to boost your productivity and streamline your workflow. Save it, share it, and level up your version control game! 💡 🔥 General Git Tools 🔹 git init → Start a new repository 🔹 git clone <repo> → Download a remote project to your machine 🔹 git status → Check modified, staged & untracked files 🔹 git log → View commit history 🔹 git branch → List all branches 🔹 git checkout <branch> → Switch branches 🔹 git merge <branch> → Merge changes into the current branch 🔹 git stash / git stash pop → Save & restore uncommitted changes 🛠️ Staging & Commit Commands 🔹 git add <file> → Stage a specific file 🔹 git add . → Stage everything 🔹 git commit -m "message" → Save changes with a message 🔹 git push → Upload commits to remote 🔹 git pull → Fetch + merge updates 📊 Info & Debugging 🔹 git diff → View unstaged changes 🔹 git diff --staged → View staged changes 🔹 git show → Display commit details 🔹 git blame <file> → See who changed each line 🔹 git tag → List or create version tags 🌍 Remote Repository Commands 🔹 git remote -v → Show remote URLs 🔹 git remote add origin <url> → Add a remote repo 🔹 git push -u origin <branch> → Push code & set upstream 🔹 git fetch → Download updates without merging 🌱 Branching Commands 🔹 git branch <name> → Create a new branch 🔹 git checkout -b <name> → Create + switch branch 🔹 git switch <branch> → Switch branches 🔹 git branch -d <branch> → Delete a branch 🔹 git merge <branch> → Merge into current branch 🧹 Cleanup & Maintenance 🔹 git clean -f → Remove untracked files 🔹 git gc → Optimize repository 🔹 git fsck → Check repo integrity 🗂 Stash Management 🔹 git stash list → Show all stashes 🔹 git stash apply → Apply a stash safely 🔹 git stash pop → Apply & delete stash 🔹 git stash drop → Remove a stash 🔖 Save this for later. 💬 Comment your favorite Git command. 🔁 Share to help fellow developers master Git more easily. Let’s build smarter, collaborate better, and ship faster! 💙 #Git #GitCommands #GitTutorial #VersionControl #GitHub #Developers #SoftwareDevelopment #Programming #Coding #DeveloperTools #DevTips #CodeNewbie #GitWorkflow #TechTips #CodingTips #OpenSource #DevCommunity #SoftwareEngineer #WebDevelopment #MobileDevelopment #Flutter #AndroidDev #ReactNative #Kotlin #JavaScript #CleanCode #Debugging #BuildInPublic #TechCommunity #Engineering #100DaysOfCode #Automation #CodeLife #GitForBeginners #TechLearning #ProgrammingLife #CodeJourney #DeveloperLife #StackOverflow #LearningInPublic #SoftwareEngineering #CodeTips #GitBasics #DevOps #CloudDevelopers #ProductivityTools #GitMerge #GitPush #GitAdd #CommitYourCode
To view or add a comment, sign in
-
-
🚀 Cheat Sheet: Git Survival Guide — Master the Art of Version Control! Ever found yourself tangled in Git branches, merge conflicts, or lost commits? You’re not alone. 😅 Every developer has faced the chaos at some point — but the good news is: Git is predictable once you understand its logic. Let’s dive into the Git Survival Guide — a mix of theory, must-know commands, and practical wisdom 🧠 🧠 The Theory — What Git Really Is Git isn’t just a tool for saving versions — it’s a content-addressable version database. Every change (commit) creates a snapshot of your project and stores it as a commit object identified by a unique hash (SHA-1). These snapshots are linked like a chain, forming your project’s history. Branches are just pointers to specific commits — making Git lightweight and fast. Understanding this makes commands like reset, revert, and rebase much less scary! 🧩 Core Git Workflow Here’s the simplest mental model: Working Directory → Staging Area → Repository You modify files in your working directory, stage them using git add, and commit them to your repository with git commit. From there, you push changes to remote repos or pull updates from teammates. ✅ Best Practices 🧩 Commit often, commit small. One logical change = one commit. 🧠 Use meaningful commit messages. Example: “Fix login timeout issue” > “update code”. 🧹 Don’t commit secrets or binaries. Add them to .gitignore. 🔒 Protect your main/master branch. Require PR reviews & approvals. 🚧 Use feature branches for new work — avoid coding directly on main. ⏱️ Rebase before merge for a clean, linear history. 💬 Review diffs before committing. Always check with git diff --cached. 💡 Pro Tips & Tricks git log -p → View code differences in commit history git reflog → Recover lost commits (lifesaver!) git cherry-pick <hash> → Apply a specific commit from another branch git blame <file> → Find who modified a line git bisect → Binary search to find which commit broke something git diff --color-words → Perfect for reviewing text/documentation changes git alias → Create short custom commands (e.g., git lg for log graph) 🧭 Mental Model to Survive Git Think of Git as a timeline of snapshots. Every action (add, commit, push) just moves or copies your project pointer. Nothing truly “disappears” — Git remembers everything. 🔍 ✨ Final Thoughts Mastering Git is not about memorizing commands — it’s about understanding what happens under the hood. Once you do, Git becomes your best teammate — not your worst nightmare. 💪 💬 What’s your favorite Git trick or a command that saved your day? Drop it in the comments! 👇 🔖 Save this post — it’s your go-to Git Survival Guide! Cheat sheet: Git survival guide: https://lnkd.in/eVtd3kcd #Git #DevOps #VersionControl #GitTips #SoftwareEngineering #Coding #CareerGrowth #GitCheatSheet #GitCommands
To view or add a comment, sign in
-
🚀 𝐓𝐡𝐞𝐬𝐞 𝐆𝐢𝐭 𝐓𝐫𝐢𝐜𝐤𝐬 𝐒𝐚𝐯𝐞𝐝 𝐌𝐞 𝐅𝐫𝐨𝐦 𝐋𝐨𝐬𝐢𝐧𝐠 𝟑 𝐃𝐚𝐲𝐬 𝐨𝐟 𝐖𝐨𝐫𝐤 — 𝐍𝐨 𝐓𝐮𝐭𝐨𝐫𝐢𝐚𝐥 𝐓𝐞𝐥𝐥𝐬 𝐘𝐨𝐮 𝐓𝐡𝐢𝐬. (Real Issues • Real Fixes • Real Industry Knowledge) Everyone knows git add → git commit → git push. But nobody talks about the nightmare real-world problems that happen in teams — and the Git tricks seniors use to fix them in seconds. Here are the battle-tested Git lessons you only learn after 💥 breaking production, 💥 losing commits, 💥 messing up merges, 💥 and recovering at 2 AM. Save this — these WILL save your job one day. 👇 🧠 1️⃣ “Lost All My Work By Accident” → Recover With Reflog Problem: You reset, hard deleted, or switched branches… and your entire work vanished. Secret Senior Solution: git reflog This shows every movement of HEAD. You can recover commits you thought were dead forever. Real-World Tip: Reflog is your time machine. Every senior dev uses it. Juniors don’t even know it exists. 🔄 2️⃣ “My Branch Is 200 Commits Behind” → Fix With Rebase Problem: Your feature branch diverged from main, causing massive merge conflicts. Secret Senior Move: git pull --rebase Brings your commits ON TOP of latest main. Why Seniors Use It: Cleaner history Fewer conflicts Looks like work was done after main’s changes ⚡ 3️⃣ “Merged Wrong Code Into Main” → Undo Without Breaking History Problem: You merged a bad PR into main. Solution Seniors Use: git revert <commit-id> Creates a new commit that undoes the wrong merge. Never use: ❌ git reset --hard on main → you’ll destroy the team’s history. 🎭 4️⃣ “Someone Broke the App… Who Did It?” → Use Git Blame Problem: A bug suddenly appears in production. Secret Senior Tool: git blame <file> Tells you EXACTLY: who wrote that line, when, and in which commit. This saves HOURS of debugging. 🔍 5️⃣ “A Bug Exists, But I Don’t Know Which Commit Added It” → Bisect This is the secret tool seniors SWEAR by. Command: git bisect start git bisect bad git bisect good <old-commit> Git automatically finds the exact commit where the bug was introduced. Massive time saver. 🗃️ 6️⃣ “I Want To Experiment Without Risk” → Stash Like a Pro Problem: You need to switch branches urgently, but your current changes are half-done. Senior Fix: git stash push -m "wip-login-feature" Saves your work safely. Later: git stash apply or git stash pop Pro Secret: Keep your stashes named and organized. Juniors use stash blindly and lose work. 🧨 7️⃣ “Need To Bring Only One Commit From Another Branch” → Cherry-pick Instead of merging a whole branch, do: git cherry-pick <commit-id> When seniors want just one fix, not the whole branch — this is the trick. 🧩 8️⃣ I Pushed to Wrong Branch!” → Safe Reset Do NOT do: git reset --hard on shared branches. Instead: git revert or git reset --soft (keeps your changes staged so you don’t lose work) Follow me Mazharuddin Farooque for more real-world developer insights and senior-level engineering secrets.
To view or add a comment, sign in
-
🚀 Challenge — Git Merge Conflicts Made Easy! 💡 Every developer faces it — that dreaded "merge conflict" message 😅 But don’t worry — it’s not an error, it’s just Git asking you to make the final decision. Here’s how to understand, handle, and master Git merge conflicts 👇 ⚡ What is a Merge Conflict? When Git can’t automatically combine code changes from different branches, it stops and asks you to choose which version to keep. Example scenario: You and your teammate edited the same line in a file. Git doesn’t know which one is correct — that’s a conflict. 🧩 How to Handle Merge Conflicts 1️⃣ Run the merge command: git merge feature/login If conflicts occur, Git will show: CONFLICT (content): Merge conflict in index.js 2️⃣ Open the conflicted file: You’ll see markers like: <<<<<<< HEAD Your code here ======= Teammate’s code here >>>>>>> feature/login 3️⃣ Manually edit the file: Decide which version (or both) to keep — then delete the markers. 4️⃣ Mark the conflict as resolved: git add index.js git commit ✅ Done! Conflict resolved like a pro. 💡 Pro Tips ⭐ Always pull latest changes before merging: git pull origin main ⭐ Use VS Code’s “Source Control” tab — it visually highlights conflicts. ⭐ For complex merges, use: git mergetool 🔥 Key Takeaway Merge conflicts are not scary — they’re communication checkpoints between developers. Handle them with patience and teamwork 🧠 🚀 I’m sharing one practical Git concept daily in my #FullStackDeveloperJourney — from Git → Docker → Linux → MERN → DevOps. Follow to learn hands-on tips that make you a better engineer every day! 💪 #Git #GitHub #VersionControl #MergeConflict #Developers #SoftwareEngineering #FullStackDeveloper #MERNStack #DevOps #CodingJourney
To view or add a comment, sign in
-
-
✅ *Git & GitHub Interview Questions & Answers* 🧑💻🌐 *1️⃣ What is Git?* *A:* Git is a distributed version control system to track changes in source code during development.*2️⃣ What is GitHub?* *A:* GitHub is a cloud-based platform that hosts Git repositories and supports collaboration, issue tracking, and CI/CD.*3️⃣ Git vs GitHub* - *Git:* Version control tool (local) - *GitHub:* Hosting service for Git repositories (cloud-based) *4️⃣ What is a Repository (Repo)?* *A:* A storage space where your project’s files and history are saved.*5️⃣ Common Git Commands:* - `git init` → Initialize a repo - `git clone` → Copy a repo - `git add` → Stage changes - `git commit` → Save changes - `git push` → Upload to remote - `git pull` → Fetch and merge from remote - `git status` → Check current state - `git log` → View commit history *6️⃣ What is a Commit?* *A:* A snapshot of your changes. Each commit has a unique ID (hash) and message.*7️⃣ What is a Branch?* *A:* A separate line of development. The default branch is usually `main` or `master`.*8️⃣ What is Merging?* *A:* Combining changes from one branch into another.*9️⃣ What is a Pull Request (PR)?**A:* A GitHub feature to propose changes, request reviews, and merge code into the main branch.*🔟 What is Forking?* *A:* Creating a personal copy of someone else’s repo to make changes independently.*1️⃣1️⃣ What is .gitignore?* *A:* A file that tells Git which files/folders to ignore (e.g., logs, temp files, env variables).*1️⃣2️⃣ What is Staging Area?* *A:* A space where changes are held before committing.*1️⃣3️⃣ Difference between Merge and Rebase* - *Merge:* Keeps all history, creates a merge commit - *Rebase:* Rewrites history, makes it linear *1️⃣4️⃣ What is Git Workflow?* *A:* A set of rules like Git Flow, GitHub Flow, etc., for how teams manage branches and releases.*1️⃣5️⃣ How to Resolve Merge Conflicts?* *A:* Manually edit the conflicted files, mark resolved, then commit the changes. #ssekabirarobertsims💬 *like if you found this useful!*
To view or add a comment, sign in
-
-
💻 - Git Week 2 Day 7 – Advanced Git Tools & Final Wrap-Up As I wrap up my second week of the DevOps journey, I explored some of the advanced Git commands and tools that make version control more powerful, flexible, and reliable in real-world environments. These are the commands that help developers clean up history, undo mistakes, and manage changes efficiently — especially in team-based projects. ⸻ 🧠 1️⃣ Rebasing vs Merging • git rebase rewrites commit history to make it linear and clean. • It’s best used for your local feature branches, while merging is safer for shared branches. Example: git rebase master This moves your branch commits on top of the latest commits from master. 💾 2️⃣ Stashing Sometimes you’re in the middle of work and need to switch branches — but don’t want to commit unfinished changes. git stash Temporarily stores your modifications so you can come back to them later. Restore them with: git stash pop 🏷️ 3️⃣ Tags & Releases Tags mark specific commits as version points (like v1.0 or v2.0): git tag v1.0 git push origin v1.0 They’re great for releases or snapshots of stable versions in production. ⸻ 🍒 4️⃣ Cherry-Picking If you need one specific commit from another branch without merging the entire branch: git cherry-pick [commit-id] This copies just that commit into your current branch. ⏪ 5️⃣ Undoing & Reverting Changes • git revert [commit-id] safely undoes a commit by creating a new one that reverses its effects. • git reset --hard [commit-id] rolls back your repository to a previous commit, use carefully as it changes history. 🔒 6️⃣ SSH Authentication Instead of entering your username and password each time you push or pull, you can connect to GitHub securely using SSH keys: ssh-keygen -t rsa -b 4096 -C "your@email.com" Add the public key to GitHub → Settings → SSH and GPG Keys. This makes Git operations faster and more secure — especially when automating with scripts or CI/CD pipelines. 🧩 Final Thoughts on Git & GitHub Over these seven days, I’ve learned how to: ✅ Initialise and configure Git ✅ Manage commits and branches ✅ Handle merges and conflicts ✅ Sync repositories with GitHub ✅ Explore advanced tools for clean version control Git has become a tool I can now use confidently to track, collaborate, and maintain cleaner project histories, a key foundation for every DevOps engineer. ⸻ Next Up: I’ll be diving into Bash scripting such as learning how to automate Linux commands, handle input/output, and build scripts to support real DevOps workflows. #Git #GitHub #DevOpsJourney #VersionControl #LearningInPublic #Bash #CloudComputing
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