Git & GitHub Basics for DevOps Engineers

Day 2 of #30DaysOfDevOps — Git & GitHub Basics Every DevOps engineer lives inside Git. If you don't understand how Git works, collaboration and CI/CD pipelines become a nightmare. Let's break it down. 1. What is Version Control? Version control tracks every change made to your codebase over time. Think of it as an unlimited undo button for your entire project — roll back anything, see who changed what, and work on multiple features in parallel. 2. Why Git? Git is distributed — every developer has a full copy of the repo locally. No internet? You can still commit, branch, and diff. It's the industry standard that every CI/CD tool integrates with natively. 3. The Three States of Git Working Directory — where you edit files Staging Area — where you prepare changes before committing Commit History — permanent snapshots of your project git add index.html git commit -m "Add landing page structure" 4. Essential Git Commands git init — create a new local repository git status — see what's changed and what's staged git add . — stage all modified files git commit -m "msg" — save a snapshot git log --oneline — view a clean commit history git diff — see exactly what changed before staging 5. Branching & Merging Branches let you work in isolation without touching the main codebase. git checkout -b feature/user-auth git checkout main git merge feature/user-auth 6. Connecting to GitHub git remote add origin https://lnkd.in/gQZps_k7 git branch -M main git push -u origin main 7. Resolving Merge Conflicts Conflicts happen when two branches edit the same lines. Git marks them: <<<<<<< feature/user-auth const port = 4000 ======= const port = 3000 >>>>>>> main Open the file, pick the correct version, remove the markers, then: git add app.js git commit 8. Challenges for Today 1. Configure your Git username and email globally. 2. Create a folder, initialize a repo, add files, and make your first commit. 3. Create a branch called feature-branch, make a change, and commit it. 4. Merge the feature branch into main and push to GitHub. Try them out and share what you build. Post 2 drops later today — Git Advanced: Rebase, Cherry-pick & Conflict Resolution. #DevOps #Git #GitHub #VersionControl #30DaysOfDevOps #LearningInPublic #DevOpsEngineer #CloudComputing

To view or add a comment, sign in

Explore content categories