My Git learnings & experiments Hey LinkedIn — I spent time today revisiting Git fundamentals and ran a few hands-on experiments. Here’s the cleaned-up, practical summary of what I learned and why it matters 🔧 Repo setup — the basic flow Commands I ran and why: # create a repo locally cd <your-directory> git init # stage everything git add . # rename (or set) the main branch git branch -M main # renames current branch to "main" (or creates it if not present) # create first commit git commit -m "first commit on branch main" # push to remote and set upstream git push -u origin main Notes: main is a convention (a modern replacement for master) — you can name the branch anything, but main is commonly used for clarity and inclusiveness. git push -u origin main sets the upstream so future git push works without specifying branch. 🧠 Staging, commits, and branch context — key clarifications A few important details I confirmed by practicing: git add stages changes into the index (the staging area) which is repository-wide — not “attached to a branch” in a direct sense. Commits are created on whichever branch your HEAD currently points to. So: If you are on feature and run git commit, the commit belongs to feature. Pushing what ends up on the remote branch depends on which ref you push. Common gotcha I clarified: git push origin main attempts to push your local branch named main to origin/main. If you want to push the current branch to the remote main branch, you must explicitly push your current HEAD to that ref, e.g.: # push current branch to remote branch named main git push origin HEAD:main That command updates origin/main with the commits from your current branch (HEAD). This explains why changes can appear on main even when you were “on” another branch — because the push target was explicitly set to main. Takeaway: Always double-check git status, git branch, and the exact git push refspec you use before pushing to protected branches like main. #Git #GitCommands #VersionControl #DevOps #SoftwareEngineering #CodingJourney #LearningInPublic #100DaysOfCode #TechLearning #ProgrammersLife #DeveloperTools #SoftwareDevelopment #CodeNewbie #EngineeringExcellence #TechCommunity
Revisiting Git fundamentals and experiments
More Relevant Posts
-
💻 - Git Week 2 Day 2 – Branching & Comparing Changes After learning how to set up Git and make my first commits, today I focused on branching — one of the most powerful features of Git that allows you to experiment, develop, and test new ideas without touching your main project timeline. ⸻ 🌿 Creating and Viewing Branches • git branch branch-name — creates a new branch. • git branch — lists all branches and shows which one you’re currently on (* marks the active branch). • By default, this is usually master (or main). ⸻ 🔄 Switching Between Branches • git checkout branch-name — switches to an existing branch. • git switch branch-name — does the same thing but with a newer, cleaner command. Create and switch in one step: • git checkout -b branch-name • or • git switch -c branch-name This creates a new branch and immediately moves you into it — perfect for starting a new feature or experiment. ⸻ ⚖️ Comparing and Merging Branches To compare your new branch with the main one: • git diff master — shows the differences between your branch and the main timeline. When your work is ready to be merged back into the main branch: • git merge branch-name — merges your branch changes into master (or main). To see which branches have already been merged: • git branch --merged To delete a branch: • git branch -d branch-name — deletes it safely (if merged). • git branch -D branch-name — force deletes it (even if unmerged). To see all branches, including remote ones: • git branch -a ⸻ Branching helped me understand how developers collaborate and work on multiple features at once without affecting the main project. It’s like creating alternate timelines that can later be merged back into the main storyline — a perfect analogy for version control. ⸻ Next Up: I’ll be learning how to: • Ignore files using .gitignore. • View changes using git diff. • Unstage files with git restore –staged. If you’re following my DevOps journey, stay tuned as I continue learning and applying version control in real-world projects 🚀 #Git #DevOpsJourney #VersionControl #CloudComputing #GitHub #LearningInPublic
To view or add a comment, sign in
-
-
🚀 Why Git Changed Everything in Software Development Remember the days of "final_version_FINAL_v2_REALLY_FINAL.doc"? Git solved this chaos for developers worldwide, and here's why it matters: What makes Git powerful: ✅ Distributed Architecture—Every developer has the complete project history. No single point of failure; work offline seamlessly. ✅ Branching Made Easy—Experiment fearlessly. Create branches in seconds; merge when ready. Feature development has never been smoother. ✅ Collaboration at Scale—Whether you're a solo developer or part of a 1000+ person team, Git handles it. Code reviews, pull requests, and conflict resolution are built right in. ✅ Time Travel for Code—Made a mistake? Revert instantly. Need to debug? Check out any previous version. Your project's complete evolution is preserved. Real Impact: → Teams ship features 3x faster with proper Git workflows. → Code conflicts reduced by implementing branch strategies. → Onboarding new developers becomes significantly easier. → Open-source collaboration enabled at unprecedented scale Pro tip: Master these Git commands and you'll be ahead of 80% of developers: git rebase (for clean history) git cherry-pick (selective commits) git bisect (automated debugging) git stash (quick context switching) Git isn't just a tool—it's the foundation of modern software development. From startups to tech giants, it's the standard for a reason. What's your favourite Git workflow or command? Drop it in the comments! 👇GitHub #Git #VersionControl #SoftwareDevelopment #DevOps #Programming #TechTips #Developers #CodingLife
To view or add a comment, sign in
-
-
🚀 Understanding the Staging Area in Git If you’ve ever worked with Git, you’ve probably come across the term **“staging area”** — but what exactly does it do? 🤔 Think of Git as a **three-step workflow**: 1. **Working Directory** – where you make changes to your files. 2. **Staging Area (Index)** – a middle ground where you prepare specific changes for your next commit. 3. **Repository** – where committed snapshots are stored permanently. 💡 **The staging area** acts like a “preview” zone. It lets you: * Review and control what changes go into your next commit. * Commit only part of your edits instead of *everything* you’ve modified. * Keep your history clean and meaningful. Example: git add file1.js # Moves changes to the staging area git status # Shows what's staged and what's not git commit -m "Fix login bug" # Commits only the staged changes In short — the staging area gives you **precision and flexibility**. Instead of saving every change, you decide exactly what story your next commit tells. 📖 How do *you* use the staging area in your Git workflow? Do you commit often, or batch your changes? #Git #VersionControl #SoftwareDevelopment #DevOps #CodingTips #GitBasics
To view or add a comment, sign in
-
Git gud at Git. Seriously, it will save your career one day. Git is your safety net when projects break or when multiple developers push changes at the same time. If you learn to use it properly, you can recover fast, collaborate smoothly, and avoid losing work. Here’s how to get better at Git: • Commit often with clear, descriptive messages • Create feature branches instead of committing to main • Pull and merge regularly to stay in sync • Learn how to revert and stash when something breaks • Use Git log and blame to understand the history of your code • Practice on side projects until Git commands feel natural Once you understand Git deeply, you stop fearing mistakes and start coding with confidence. #Git #CodingTips #SoftwareEngineering #Developers #DevLife #VersionControl #LearnToCode
To view or add a comment, sign in
-
Week 7: I & Git Are Finally on Speaking Terms! 🤝 There was a time when Git and I were merely acquaintances. We knew of each other, but hadn’t built a real connection. It was awkward at first. This week? We're chatting. Maybe even sharing memes. 😄 Here’s what clicked: 🔧 Core Commands Mastered: `git init`, `add`, `commit`, `status`, `branch`, `checkout`, `merge`, `push`, `pull`, `revert`, `restore`, `reset`, and `remote` 🚀 Key Wins: - Created & managed branches like `feature/add-about-page` - Resolved my first merge conflict (goodbye `<<<<<<< HEAD` confusion!) - Connected local repos to GitHub via SSH - Used `git revert` for safe undos & `checkout` for smooth context switching 💡 Big Takeaway: Git isn’t just version control it’s the foundation of collaboration, clean history, and CI/CD readiness. 🎯 Why This Matters: Git is more than saving code it's about enabling teamwork, maintaining clean project history, and building a workflow that supports iteration, review, and continuous integration. Mastering Git means building a stronger foundation for everything ahead in my DevOps journey. #DevOps #Git #GitHub #VersionControl
To view or add a comment, sign in
-
Understanding Git Submodules - When One Repo Isn’t Enough Almost every developer has typed this command at least once: git clone <repository-url> Easy, simple, and gets the job done. But have you ever seen this one? 👀 git clone --recurse-submodules <repository-url> If not — you’re definitely not alone. Most of us never touch it. But trust me, once you understand it, it’s a game-changer. 💡 So, what is a Git Submodule? In short, it’s a Git repository inside another Git repository. Think of it like having a mini project living inside your main project — each with its own commits, branches, and version history. For example- git submodule add https://lnkd.in/gYg8k97K utils This command adds another repo (shared-utils) inside your project folder (utils/). ⚙️ What does it actually do? It lets you reuse existing code (like a shared library, config, or module) across multiple projects without copying and pasting. And the best part? You can control which version of that code your project uses. Need to update? Just pull the latest submodule changes when you’re ready. 🚀 Why use it? ✅ Reuse shared components or libraries across multiple projects. ✅ Keep dependencies version-controlled (no random code drift). ✅ Maintain cleaner, modular project structures. ⚠️ A small heads-up Submodules don’t auto-update when you pull the main repo — you’ll need to run: git submodule update --init --recursive Simple once you get the hang of it. 💪 Git submodules aren’t something you’ll use every day, but when you do, they can save tons of time, especially in multi-repo environments. Have you ever worked with Git submodules before? Did they make your life easier… or drive you a little crazy? 😅 #Git #GitSubmodules #GitTips #VersionControl #SoftwareDevelopment #FullStackDevelopment #DevLife
To view or add a comment, sign in
-
🚀 Want to Level Up Your Git Skills? If anyone is looking to strengthen their Git and version control knowledge, here’s a quick thought based on my experience that might help. 💬 Here are some practical tips to develop this skill: 1. 🔹 Start Small – Master the basics: git init, git add, git commit, git status, git log. These commands form your foundation. 2. 🧩 Work on Real Projects – Create your own project or contribute to open source. You’ll naturally learn about branches, merges, and pull requests. 3. 🌿 Understand Branching – Experiment with git branch, git checkout, and git merge. Feature branches help you code fearlessly. 4. 🧠 Learn from Mistakes – Explore git revert, git reset, and git stash. Knowing how to fix errors is part of mastering Git. 5. 💻 Use Visual Tools – Tools like GitKraken, Sourcetree, or VS Code Source Control can help you visualize commits and history. 6. 📜 Study Commit History – git log --oneline --graph shows how commits evolve. Great way to learn project structure. 7. ✍️ Follow Good Practices – Write clear commit messages, pull before pushing, and keep commits focused. 8. ⚙️ Go Advanced — Slowly – Once you’re comfortable, learn about rebase, cherry-pick, and tagging to refine your workflow. 9. 🤝 Collaborate – Team projects teach you about merge conflicts, code reviews, and PR etiquette — all essential in real-world dev. 10. 📅 Be Consistent – Use Git every day, even for side projects or notes. Repetition builds true confidence. --- 💡 Remember: Git isn’t just a tool — it’s your project’s time machine. The more you use it, the better you’ll understand how powerful and forgiving it really is. #Git #VersionControl #DeveloperTips #CodingJourney #GitHub #Programming
To view or add a comment, sign in
-
“Git Rebase or Git Merge, Which one Should You Use?” 🤔 I’ve been getting this question a lot from devs lately, so let’s settle it once and for all 👇 When you start collaborating on real projects, one of the first Git dilemmas you’ll face is this: ➡️ Should I use git merge or git rebase? They both combine changes from one branch into another... But they work very differently. 🧩 Git Merge: The Honest Storyteller When you merge, you’re saying: “Let’s bring these branches together and keep every commit exactly as it happened.” It preserves history, every branch, every commit, like reading your project’s full diary. ✅ Safe for shared branches (main, develop) ❌ Can make commit history look messy 🔄 Git Rebase: The Clean Editor When you rebase, you’re saying: “Let’s replay my changes on top of the latest branch so it looks like I built them in sequence.” It rewrites history for a cleaner, linear timeline. ✅ Cleaner and easier-to-follow commit history ❌ Risky on shared branches (don’t rebase what others already pulled!) ⚖️ So which should you use? 💡 Use MERGE when you’re working in a team and need full traceability. 💡 Use REBASE when you want a clean history before merging your feature. 🚀 My take? Neither is superior, they’re tools. A great engineer knows when to use each. If you want the full story → Merge. If you want a clean story → Rebase. Both can live happily in a healthy Git workflow. So next time someone asks, “Git merge or git rebase?” Tell them: 👉 Use whichever helps your team understand the story of your code better. 💪 Which side are you on, Team Merge or Team Rebase? 😅👇 #Git #SoftwareEngineering #Developers #CodeReview #Programming #Collaboration #LearningMindset
To view or add a comment, sign in
-
-
💻 Mastering Git: The Subtle Art of Merge, Rebase & Pull ⚙️ Every developer eventually confronts the trio that defines Git’s core — Merge, Rebase, and Pull. Though they may seem similar, their intentions and implications are strikingly distinct. 🔀 Git Merge vs Git Rebase — The Tale of Two Histories ➡️Git Merge - Blends two branches together by creating a new merge commit, preserving each branch’s timeline in its raw authenticity. It’s the art of uniting progress without rewriting the past, ensuring that every divergence remains traceable. ➡️Git Rebase - Repositions your commits on top of another branch, forging a linear and refined commit history. It’s like re-scripting your contribution from a fresher base, yielding elegance and clarity — though risky on shared branches, as it rewrites history. 💡 Pro Insight: Use Merge when teamwork demands transparency. Use Rebase when refinement and linearity matter most. 🌱 Git Merge vs Git Pull — Integration vs Synchronization While they may sound alike, their roles diverge in execution. ➡️Git Merge - Manually integrates updates from one local branch into another, giving you deliberate control over every consolidation. ➡️Git Pull - Performs a fetch and merge in one sweep, retrieving the latest changes from a remote repository and uniting them with your current branch. It’s your synchronization conduit, ensuring your local environment mirrors the central codebase. ⚖️ In essence: 🔸Merge integrates local branches. 🔸Pull synchronizes with the remote. #Git #GitCommands #VersionControl #SoftwareDevelopment #Programming #DevOps #DevelopersCommunity #CodingBestPractices #TechInsights #LearningNeverStops #CodeWisdom #Rebase #Merge #PullRequest #GitHub
To view or add a comment, sign in
-
💣Git: The Art of Controlled Chaos When I first learned Git, it felt like a necessary evil. Commands to memorize. Conflicts to fix. Pushes that somehow broke everything. But over time, I realized something profound ♟️. Git isn’t just a tool for code management. It’s a tool for mental clarity 💡 . Every developer eventually learns that progress isn’t linear. We build. We break. We experiment. We roll back. Git simply makes peace with that chaos 🚑 . Each commit is a conversation with your future self, a small note saying: “Here’s what I tried, and here’s why.” Each branch is a sandbox for curiosity and every merge, a gentle reminder that ideas evolve best through collision, not isolation. Git teaches humility. Because when you open your history, you see your growth, not as a straight line of success, but as a map of every mistake that made you better. And that’s why I think Git is more than version control. It’s creative control. It gives developers the courage to explore without fear, to break without guilt, to build with intention. So yes, Git can be frustrating but so is anything that reveals how your mind truly works. #Git #Programming #SoftwareCraftsmanship #DeveloperMindset #Innovation #TechLeadership
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