𝗧𝗵𝗮𝘁 "𝗪𝗵𝗮𝘁 𝗱𝗶𝗱 𝗜 𝗲𝘃𝗲𝗻 𝗱𝗼 𝗵𝗲𝗿𝗲?" 𝗳𝗲𝗲𝗹𝗶𝗻𝗴 𝘄𝗵𝗲𝗻 𝗹𝗼𝗼𝗸𝗶𝗻𝗴 𝗮𝘁 𝗼𝗹𝗱 𝗰𝗼𝗺𝗺𝗶𝘁𝘀 𝗶𝘀 𝘁𝗵𝗲 𝘄𝗼𝗿𝘀𝘁. 🤦♂️ We’ve all been there: scrolling through a Git history filled with "updates," "fix," or "temp," and even the person who wrote it has no idea what changed. To solve this, I’ve started using a customized CommitLint configuration. No more guessing—just clean, structured, and searchable history. 🚀 𝗪𝗵𝘆 𝘂𝘀𝗲 𝗖𝗼𝗺𝗺𝗶𝘁𝗟𝗶𝗻𝘁? It acts as a gatekeeper for your Git messages. If the commit doesn't follow the rules, it doesn't get in. It forces the team (and my future self) to be intentional. By default, CommitLint is a strict gatekeeper. If your message doesn't follow the type(scope): subject format, it stops the commit entirely. No exceptions. 𝘽𝙪𝙩 𝙄 𝙙𝙞𝙙𝙣'𝙩 𝙨𝙩𝙤𝙥 𝙖𝙩 𝙩𝙝𝙚 𝙙𝙚𝙛𝙖𝙪𝙡𝙩𝙨. 𝙄’𝙫𝙚 𝙖𝙙𝙙𝙚𝙙 𝙘𝙪𝙨𝙩𝙤𝙢𝙞𝙯𝙖𝙩𝙞𝙤𝙣𝙨 𝙩𝙤 𝙛𝙞𝙩 𝙢𝙮 𝙨𝙥𝙚𝙘𝙞𝙛𝙞𝙘 𝙥𝙧𝙤𝙟𝙚𝙘𝙩 𝙣𝙚𝙚𝙙𝙨: ✅ 𝗖𝘂𝘀𝘁𝗼𝗺 𝗧𝘆𝗽𝗲𝘀: Added specific types like perf for performance and build for dependency shifts. ✅ 𝗦𝗰𝗼𝗽𝗲 𝗘𝗻𝗳𝗼𝗿𝗰𝗲𝗺𝗲𝗻𝘁: Forced the use of scopes (like auth, api, or ui) so I know exactly where the change happened at a glance. ✅ 𝗛𝗲𝗮𝗱𝗲𝗿 𝗟𝗲𝗻𝗴𝘁𝗵: Capped headers at 100 characters to keep the Git history readable. 𝗧𝗵𝗲 𝗖𝗹𝗲𝗮𝗻 𝗦𝗲𝘁𝘂𝗽: 𝗡𝗮𝘁𝗶𝘃𝗲 .𝗴𝗶𝘁𝗵𝗼𝗼𝗸𝘀 ⚓ While many developers use the Husky npm package for this, I preferred a more lightweight approach. I’ve used a custom .githooks folder in my project root to manage the hooks directly. This keeps the repo clean and ensures the rules are enforced the moment you hit `git commit`. 𝗧𝗵𝗲 𝗿𝗲𝘀𝘂𝗹𝘁? 𝗔 𝗚𝗶𝘁 𝗵𝗶𝘀𝘁𝗼𝗿𝘆 𝘁𝗵𝗮𝘁 𝗮𝗰𝘁𝘂𝗮𝗹𝗹𝘆 𝘁𝗲𝗹𝗹𝘀 𝗮 𝘀𝘁𝗼𝗿𝘆: feat(auth): add user registration fix(api): resolve pagination issue refactor(payments): simplify checkout logic 𝗪𝗮𝗻𝘁 𝘁𝗼 𝘀𝗲𝗲 𝘁𝗵𝗲 𝗳𝘂𝗹𝗹 𝘀𝗲𝘁𝘂𝗽? 📖 Read about my customization here: https://lnkd.in/dhgWjZvi 🛠️ Grab the config file here (i have commented some lines, to not make it super strict but you can try things): https://lnkd.in/dCM3QHkU Stop treating your commit history like the "wild west." Start building a legacy of clean code! 🛠️✨ Do you prefer a native .githooks approach or do you stick with Husky? Let’s talk below! 👇 #Git #CommitLint #Github #BitBucket #Gitlab #CleanCode #WebDevelopment #ProgrammingTips #SoftwareEngineering #DevTools #OpenSource #Backend #DevOps #Github
Improve Git Commit History with CommitLint
More Relevant Posts
-
🧠 TIL: git update-index --skip-worktree - a tiny git flag that made my dev loop so much cleaner. Every project has those files - the ones that are tracked in the repo, but you need to tweak locally just to get a sane dev experience. For me today, it was two BullMQ processor files that spin up cron jobs (heartbeats, cache clearers) on every boot. Great in staging/prod. Annoying as heck when I'm just trying to debug something unrelated on my laptop. The catch: they're tracked files. So .gitignore doesn't help. .git/info/exclude doesn't help. The moment I comment out a scheduler to quiet things down, my git status lights up - and one stray git add . away from shipping a broken commit. The usual workaround is stash / pop - and it's genuinely painful: Before every branch switch → git stash After switching → git stash pop Forget once → you lose your local tweaks or hit merge conflicts on your own stash Multiple local tweaks across multiple files = a growing stash stack you have to babysit git status still nags you until you stash And good luck if you want to commit other changes without accidentally including these One line fixes all of that: git update-index --skip-worktree path/to/file Now git pretends the file matches the index. No more noise in status, no accidental add, no stash dance. Your local edits just… stay local. Forever. Silently. Undo is equally simple, whenever you want: git update-index --no-skip-worktree path/to/file One caveat worth knowing: if upstream ever changes that file, you'll need to --no-skip-worktree, stash, pull, and re-flag. But for files that rarely change upstream, it's a massive quality-of-life win. If you've ever muttered "why is this file showing up in my diff AGAIN" - give this a try. 🙌 Found this via this great little writeup: https://lnkd.in/g_JqgPG7 #git #developerproductivity #softwareengineering #TIL
To view or add a comment, sign in
-
🐙 Git & GitHub: The Superpower Every Developer Needs If you write code, you need version control. Period. And Git is how over 70% of developers collaborate, track changes, and avoid "final_FINAL_v3" disasters. Here’s a quick Git cheat sheet based on what actually matters day-to-day: 🔧 First-time setup git config --global user.name "Your Name" git config --global user.email "your@email.com" 📁 Start tracking a project git init ✅ Stage & commit changes git add <file> git commit -m "Meaningful message" # Skip staging for small changes: git commit -a -m "Message" 🌿 Branching (your best friend) git branch <branch-name> # create git checkout <branch-name> # switch git checkout -b <branch> # create + switch git merge <branch> # merge into current git branch -d <branch> # delete ☁️ Connect to GitHub git remote add origin <repo-URL> git push --set-upstream origin main # After first time: git push origin ⬇️ Pull updates from GitHub git pull origin 📜 See what happened git status git log --oneline ⏪ Undo mistakes (safely) # Revert = new commit that undoes old one (safe for shared branches) git revert HEAD # Reset = move branch pointer back (careful!) git reset <commit-hash> # Amend = fix last commit message or add forgotten files git commit --amend -m "Better message" 📦 Clone someone’s repo git clone <URL> <optional-folder-name> 💡 Pro tips: • git branch -a → see all local + remote branches • git push origin <branch-name> → push a new branch to GitHub • git pull = git fetch + git merge Git is not GitHub — GitHub is just the most popular place to host Git repos (owned by Microsoft since 2018). ❓ What’s the one Git command you couldn’t live without? For me — git log --oneline --graph (visualizes branches beautifully). 🎯 Follow Virat Radadiya 🟢 for more..... #Git #GitHub #VersionControl #DevTools #Programming #SoftwareEngineering
To view or add a comment, sign in
-
Day 2 of #30DaysOfDevOps — Post 2 Once you know basic Git, the next step is learning how to use it like a pro. These are the commands that separate junior engineers from senior ones. 1. Git Rebase Merge creates a new commit tying two branches together. Rebase moves your entire branch on top of another — keeping history straight and clean. git checkout feature/api-refactor git rebase main Your commits get replayed one by one on top of main. No messy merge commits cluttering the log. 2. Interactive Rebase Before merging, clean up your commit history so reviewers don't see every "fix typo" and "oops" commit. git rebase -i HEAD~4 In the editor: - squash — combine commits into one - reword — rename a commit message - drop — remove a commit entirely A clean history is a sign of a professional engineer. 3. Git Cherry-pick Need just one commit from another branch? Don't merge the whole thing. git checkout release/v2.1 git cherry-pick 7d3f91b That single commit is now applied to your current branch. Perfect for backporting a hotfix. 4. Amending Commits Caught a mistake right after committing? Fix it before pushing. Wrong message: git commit --amend -m "Add rate limiting to auth endpoint" Forgot a file: git add middleware/ratelimit.js git commit --amend --no-edit Rule: never amend a commit that's already on a shared branch. 5. Reset vs Revert Two ways to undo — very different consequences. git reset --soft HEAD~1 — undo commit, keep changes staged git reset --mixed HEAD~1 — undo commit, keep changes unstaged git reset --hard HEAD~1 — undo commit and wipe all changes git revert HEAD — create a new commit that undoes the previous one On shared branches, always use revert. Reset rewrites history — dangerous for teammates. 6. Git Stash Need to switch branches but not ready to commit? Stash your work. git stash git checkout main Come back later and restore it: git stash pop You can have multiple stashes and name them too: git stash save "half-done login validation" 7. Git Hooks Hooks run scripts automatically at key Git events. A pre-commit hook can enforce code quality before anything gets committed. cd .git/hooks nano pre-commit #!/bin/bash echo "Running lint check..." npm run lint if [ $? -ne 0 ]; then echo "Lint failed. Commit blocked." exit 1 fi chmod +x pre-commit Now no one on your team can commit broken code. 8. Challenges for Today 1. Rebase a feature branch on top of main and verify the log looks linear. 2. Use interactive rebase to squash 4 commits into a single meaningful commit. 3. Cherry-pick a bug fix commit from one branch and apply it to another. 4. Practice all three reset modes and observe how your working directory changes. Drop your solutions or questions in the comments. #DevOps #Git #GitHub #30DaysOfDevOps #LearningInPublic #DevOpsEngineer #CloudComputing
To view or add a comment, sign in
-
My git config grew over years. After a recent round of improvements I decided to write about it :) Five settings that made the biggest difference: rerere.enabled = true — Git records how you resolved a conflict. Same conflict again? Applied automatically. The sleeper hit most people don't know exists. rebase.autoSquash + autoStash + updateRefs — three settings that turn rebase from a ceremony into a one-liner. No manual stashing, automatic fixup folding, and all stacked branches move together. core.fsmonitor + untrackedCache — git status drops from hundreds of milliseconds to near-instant on large repos. A filesystem watcher replaces full directory scans. merge.conflictstyle = zdiff3 — conflict markers show three versions: yours, theirs, and the original. Once you see the common ancestor, the default style feels blind. push.autoSetupRemote + followTags — first push on a new branch, just git push. Tags travel with the code. No more -u origin branch-name, no more forgotten --tags. Full config with the story behind each section: https://lnkd.in/gymnYVQi Inspired by https://lnkd.in/g4KnmrQ9 #Git #CLI #DevTools #DeveloperProductivity
To view or add a comment, sign in
-
🚨 I was doing git pull origin dev on my feature branch for months... and I had NO idea I was doing it wrong. Let me save you from the same mistake. 👇 Here's the scenario most developers face daily — ✅ You are working on → login_api_integration branch ✅ Your teammate is working on → forgot_password_ui branch ✅ There is a common → dev branch Now dev has new updates and you want your feature branch to be up to date. What do most beginners do? (I did this too 😅) ❌ git pull origin dev Looks harmless right? But here's what actually happens internally — git fetch origin dev git merge origin/dev ← THIS is the problem It physically brings dev's commits INSIDE your feature branch. Your branch gets polluted with other people's code. Your PR becomes noisy with unnecessary merge commits. ✅ What you should actually do — git fetch origin git rebase origin/dev Think of it this way 👇 git merge = You copy all of dev's stuff into your room. Now your room has YOUR stuff + dev's stuff mixed together. 😵 git rebase = You just shift your room to the latest floor of the building. Your room still has ONLY your stuff, just placed on the latest foundation. 🏗️ Rebase does NOT bring dev's commits inside your branch. It just moves your starting point to the latest dev. Your branch stays clean with ONLY your own commits. ⚠️ But should you rebase every single time? NO. Rebase is a tool, not a ritual. Here's when to use it and when to skip it — ✅ Rebase WHEN — → Dev has new commits that affect your work → You are about to raise a PR → You want to clean up messy commits before code review ❌ Skip rebase WHEN — → Dev has no new commits since your last rebase → A teammate is also working on your same feature branch → Conflicts are too complex — a single clean merge may be better Simple rule before rebasing — Did dev get new commits? → Rebase About to raise a PR? → Rebase Teammate on same branch? → Don't rebase, use merge Dev unchanged since last rebase? → Skip it 🔑 Golden Rule — Always use rebase on your own feature branches. Never rebase shared branches like dev or main. If this helped you, share it with your team 🙌 Drop a comment if you were also doing git pull origin dev 😄 #Git #VersionControl #WebDevelopment #Programming #DevTips #SoftwareEngineering #CleanCode #TechLearning #DevCommunity #DevTips
To view or add a comment, sign in
-
-
Essential Git Commands Every Developer Should Know (Practical Guide) Git is not just about add, commit, and push. Knowing the right commands helps you manage code, collaborate safely, and recover quickly from mistakes. ⸻ 📁 Repository Setup git init – Initialize a new repository git clone <repo_url> – Clone existing repository ⸻ 📌 Tracking Changes git status – Check current changes git add <file> / git add . – Stage changes ⸻ 💾 Committing git commit -m "message" – Save changes git commit --amend – Modify last commit ⸻ 🌿 Branching git branch – List branches git checkout -b <branch> – Create & switch git switch <branch> – Switch branch ⸻ 🔀 Merge / Rebase git merge <branch> – Merge branches git rebase <branch> – Clean commit history ⸻ 🚀 Remote git pull – Get latest changes git fetch – Fetch without merging git push origin <branch> – Push code ⸻ ⏪ Undo git restore <file> – Discard changes git reset <file> – Unstage git revert <commit> – Safe undo (recommended) ⸻ 🔍 History git log --oneline – View commits git diff – Check differences ⸻ 📦 Stash git stash – Save work temporarily git stash pop – Restore work ⸻ 🧩 Practical Scenario (Hotfix) git stash → git checkout main → git pull → git checkout -b hotfix/issue → fix → commit → git push ⸻ Key Takeaways • Prefer fetch before pull • Use revert instead of reset in shared branches • Keep commits small and meaningful • Always verify using status before pushing ⸻ Mastering Git is about using the right command at the right time. #Git #VersionControl #SoftwareEngineering #Developers #DevOps
To view or add a comment, sign in
-
Here’s a powerful list of 50+ Git commands every developer should already be using. ========================================= # 🔹 Repository Setup git init # Initialize new repo git clone <url> # Clone remote repo # 🔹 Basic Workflow git status # Check current state git add <file> # Stage specific file git add . # Stage all changes git commit -m "message" # Commit changes git commit -am "message" # Stage + commit tracked files git commit --amend # Edit last commit # 🔹 History git log # Full commit history git log --oneline # Compact history git log --stat # History with stats git show <commit_id> # Show commit details # 🔹 Branching git branch # List branches git branch <name> # Create branch git branch -d <name> # Delete branch git branch -m <new_name> # Rename branch # 🔹 Switching git checkout <branch> # Switch branch git checkout -b <branch> # Create + switch git checkout <commit_id> # Checkout commit git switch <branch> # Modern switch git switch -c <branch> # Create + switch # 🔹 Merging & Rebase git merge <branch> # Merge branch git merge --no-ff <branch> # Force merge commit git rebase <branch> # Rebase branch git rebase -i HEAD~n # Interactive rebase git cherry-pick <commit_id> # Apply specific commit # 🔹 Remote git remote -v # List remotes git remote add origin <url> # Add remote git push origin <branch> # Push to remote git push -u origin <branch> # Set upstream git push --force # Force push (careful ⚠️) git pull # Fetch + merge git fetch # Fetch only git branch --set-upstream-to=origin/<branch> # 🔹 Undo / Reset git reset HEAD~1 # Undo last commit (keep changes) git reset --soft HEAD~1 # Undo + keep staged git reset --hard HEAD~1 # Reset everything git revert <commit_id> # Safe undo commit # 🔹 File Changes git restore <file> # Discard changes git clean -fd # Remove untracked files git diff # Unstaged changes git diff --staged # Staged changes git diff <branch1> <branch2> # Compare branches # 🔹 Insights git blame <file> # Who changed what git shortlog # Summary by author # 🔹 Stash git stash # Save changes git stash pop # Apply + remove stash git stash list # List stashes git stash apply stash@{n} # Apply specific stash git stash drop # Delete stash git stash clear # Clear all # 🔹 Config git config --global user.name "Your Name" git config --global user.email "your@email.com" # 🔹 Shortcuts & Help git alias # Create shortcuts git help # Open docs #git #github
To view or add a comment, sign in
-
-
I deleted the wrong file before my coffee kicked in. Again. ☕ Happy Git Friday! I can't even count the number of times this has happened. Early morning. Terminal open. Brain not fully online yet. I'm cleaning up a working directory, trimming files, moving things around. And then I realize I just deleted something I needed. Not git rm. Just rm. Gone from the filesystem. No recycle bin. No undo. Just a blank stare at the terminal and the slow realization that the file I need for today's work is gone. The first time it happened, I panicked. I started thinking about backup systems, recovery tools, whether I could rewrite it from memory. Then someone said: "It's in a git repo. Just check it out." git checkout -- filename The file came back. Exactly as it was the last time I staged it. Git had a copy in the index the entire time. I just didn't know how to ask for it. That one command has saved me more times than I'm willing to admit. All of them before the first cup of coffee. The Danger Zone (When Deletions Feel Permanent): 🔹 rm deletes from the filesystem. Git doesn't know or care. But if the file was tracked and staged, the last staged version is still in the index. You can recover it. 🔹 git add on a deleted file stages the deletion. If you accidentally delete a file and then run git add ., you've told git you meant to delete it. Now recovery requires checking out from a commit, not just the index. 🔹 git rm is intentional. It removes the file AND stages the removal. That's a deliberate action. An accidental rm followed by git checkout -- is the recovery path for unintentional deletions. ❓ Question of the Day: You deleted a file in the working directory and want to recover it from the index. Which command do you use? Ⓐ git checkout -- filename Ⓑ git add filename Ⓒ git rm filename Ⓓ git recover filename 👇 Answer and breakdown in the comments! #Git #GitOps #DevOps #DamnitRay #QOTD
To view or add a comment, sign in
-
-
Git isn't hard. You just never had someone show you the right commands. Every developer you admire uses Git every single day. It's how code gets saved, shared, tracked, and collaborated on across teams of 2 or 2,000. And most beginners avoid it because it looks scary from the outside. It isn't. Here's proof. These are the only Git commands you actually need to know to get started: Setting up git init — start a new project git clone — copy someone else's project to your machine git config — tell Git who you are Checking your work git status — see what's changed git diff — see exactly what changed line by line git log — see the full history of your project git log --oneline — same thing, but clean and compact Saving your work git add — pick which files to save git add . — pick everything at once git commit -m "msg" — actually save it with a description Working with teams git push — send your work to the cloud git pull — get everyone else's latest work git fetch — check what's new without applying it yet Fixing mistakes git revert — safely undo a change without breaking history git restore — throw away changes you don't want git stash — temporarily set work aside git stash pop — bring it back when you're ready Working with branches git branch — see all your branches git checkout -b — create a new branch and switch to it git merge — combine two branches together That's it. Not 200 commands. Not a computer science degree. Not years of experience. 30 commands — most of which you'll use every single day. Here's the honest truth about Git: The reason it feels hard isn't because it's complicated. It's because nobody sat down and explained what each command actually does in plain English. Once you understand that Git is just a system for saving snapshots of your work and sharing them with others — everything clicks. Think of it like Google Docs version history. But for code. And with superpowers. If you're learning to code right now — don't put Git off. Learn it alongside your first project. Use it from day one. Every professional developer wishes they had started earlier. Which of these commands were you most confused about before reading this — drop it below. ❤️ If this made Git feel less scary 🔖 Save this — come back to it every time you get stuck 👥 Follow for more → https://lnkd.in/dhSg-nTK #Git #GitHub #Programming #LearnToCode #SoftwareEngineering #DeveloperTools #Coding #TechForEveryone #AI #Technology
To view or add a comment, sign in
-
-
Most developers use Git every day and still panic when something breaks. They copy-paste commands from Stack Overflow and hope for the best. I know because I did the same for years. Then I actually looked inside the .git folder. Here's what I found: Git is just a key-value database. It stores 4 types of objects - blobs, trees, commits, and tags. That's the entire system. Once I understood that, every confusing command started making sense. A few things that clicked for me: → A blob stores file content, not the filename, just the raw bytes. Same content = same hash = Git never stores duplicates. → A tree is a directory snapshot. It maps filenames to blob hashes and sub-trees. Your entire project is one tree object pointing to other trees and blobs. → A commit is not a diff. It's a full snapshot of your project at that moment, plus a pointer to the parent commit. That chain of pointers is your history. → A branch is literally a text file with a 40-character hash. That's it. When you commit, Git just updates that file to the new hash. → Detached HEAD isn't scary. It just means HEAD is pointing directly to a commit instead of a branch. Create a branch from there and you're fine. Once you see this, git rebase stops being magic. It's just: save your commits as patches → reset your branch to a new base → re-apply the patches. New hashes, same changes. And merge conflicts stop feeling random. Git is literally asking: "Both of you changed the same lines, which one is right?" I put this all together in a free PDF, 11 pages, dark theme, code examples throughout. Explains Git's internals from objects to branches to merge vs rebase, as simply as I could write it. Download it from this post. Save it for the next time someone on your team panics about a detached HEAD. #Git #SoftwareEngineering 11 pages covering: - Blob, Tree, Commit objects explained simply - Why branches are just text files - HEAD and Detached HEAD demystified - Staging area (the index) - actually explained - How merge and rebase work step-by-step - Common Git mistakes + how to fix them - Full cheat sheet
To view or add a comment, sign in
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