"Mastering Git: Merging, Conflicts, and Workflows"

💻 - Git Week 2 Day 5 & 6 – Merging, Conflicts & Git Workflows This week, I focused on one of the most important parts of Git: merging branches and managing conflicts — the kind of real-world challenges that happen when multiple developers work on the same project. I also learned about common Git workflows used in DevOps teams to keep collaboration smooth and organised. ⸻ 🔀 Merging Branches After working on a feature or fix in a separate branch, you can merge it back into your main branch (usually master or main): git checkout master git merge feature-branch If everything goes smoothly, Git combines the changes automatically and creates a merge commit. To see which branches have already been merged: git branch --merged Once merged, you can delete the branch to keep things clean: git branch -d feature-branch ⚠️ Handling Merge Conflicts Conflicts occur when two branches edit the same part of a file differently. When this happens, Git pauses the merge and marks the conflicting sections like this: <<<<<<< HEAD Your version of the code ======= The other branch’s version >>>>>>> feature-branch To fix it: 1. Open the file and decide which version (or combination) to keep. 2. Remove the conflict markers. 3. Stage the file again with git add file. 4. Finish the merge with: git commit You can also use GUI tools like VS Code, GitHub Desktop, or GitKraken to resolve conflicts visually. ⸻ 🧩 Understanding Git Workflows 1️⃣ Feature Branch Workflow Each new feature or bug fix happens on its own branch. Once tested, it’s merged back into the main branch via a pull request — keeping main always clean and deployable. 2️⃣ Forking Workflow Used in open-source projects — you copy (fork) someone’s repo, make changes in your own version, then submit a pull request to merge it back into the original. 3️⃣ Gitflow Workflow A structured model with dedicated branches for features, releases, and hotfixes — used in larger teams to manage parallel development efficiently. ⸻ Learning how to merge confidently and handle conflicts made me realise Git is less about avoiding mistakes and more about managing collaboration safely. 🚀 Next Up: Advanced Git Tools & Bash Scripting I’ll be wrapping up my Git learning by briefly exploring: • Rebasing – keeping commit history clean and linear • Stashing – saving temporary work • Tags – marking specific versions • Cherry-picking – copying a single commit • Reverting – safely undoing changes • SSH keys – connecting securely to GitHub Then I’ll begin Bash scripting, where I’ll learn how to automate Linux tasks and build scripts to support DevOps workflows. #Git #GitHub #DevOpsJourney #VersionControl #LearningInPublic #CloudComputing #Bash

  • icon

Nicely explained! Merge conflicts are inevitable in collaborative work, but once you understand how to resolve them confidently, Git becomes an amazing safety net rather than a source of stress. Looking forward to your deep dive into reverting and SSH keys.

To view or add a comment, sign in

Explore content categories