🚀 Level up your version-control game: 5 obscure (and powerful) commands for Git users Whether you’re a seasoned dev, a team lead, or simply looking to sharpen your workflow, these lesser-known Git commands can help you save time, avoid headaches, and impress your collaborators. 1️⃣ git bisect When you’ve got a bug, but you don’t know which commit introduced it, this one’s gold. git bisect start git bisect bad # current commit has the bug git bisect good <old-sha> # a commit you know worked # Git will check out a midway commit for you → test → mark good/bad → repeat This binary-search style method pinpoints the problematic commit in far fewer steps than manually rolling back. DEV Community+1 Why it’s useful: Saves time especially in big repos, gives you confidence in isolating a root cause. 2️⃣ git notes Ever wished you could attach metadata to a commit without changing the commit itself? Enter git notes. git notes add -m "Reviewed by Jane on 2025-10-19" <commit-sha> git log --show-notes Because notes don’t change the commit hash, you can annotate later without rewriting history. DEV Community+1 Why it’s useful: Great for teams / audits / code reviews to leave non-intrusive remarks or tagging. 3️⃣ git instaweb Want a quick visual interface for your repo without leaving the terminal? Try: git instaweb It launches a minimal web server for you, allowing you to browse commits, branches, diffs in your browser. DEV Community+1 Why it’s useful: Especially handy for showing non-technical stakeholders a branch history, or simply for inspecting the repo faster than CLI. 4️⃣ git reflog Mistakes happen. Commit you shouldn’t have? Branch you orphaned? git reflog # shows “where HEAD and branches have been” over time # then you can checkout or reset to a past state Essentially, it’s your safety net. GitHub+1 Why it’s useful: Gives you a second chance. Helps recover commits that seemingly “disappeared”. 5️⃣ git commit --allow-empty Sometimes you want to create a commit with no file changes — maybe to trigger a CI build, mark a milestone, or set a base for history rewrites. git commit --allow-empty -m "Initialize repository skeleton" The “empty commit” isn’t just a novelty — it can shape your repo’s timeline. myme.no Why it’s useful: Clears the path for consistent tagging, or marks organizational checkpoints without modifying code. #Git #GitHub #OpenSource #DevCommunity #DeveloperTools #CodeNewbie #SoftwareEngineering #ProgrammingTips #WebDevelopment #TechCommunity #DevLife #100DaysOfCode #LearnToCode #CleanCode #CodingJourney #TechCareers #SoftwareDeveloper #FullStackDevelopment #Productivity #VersionControl
"5 Powerful Git Commands for Developers"
More Relevant Posts
-
Are your Git commits just "fixed stuff" and "updated code"? I just published an article on Conventional Commits - a simple yet powerful standard to make your commit history professional and readable. What's Inside: ✅ Complete guide to Conventional Commits ✅ Real-world examples (Bad vs Good) ✅ All commit types and scopes explained ✅ Tools & automation setup guide ✅ Best practices and common mistakes ✅ Downloadable cheat sheet Quick Preview: Format: <type>(scope): description Examples: feat(auth): add user login fix(ui): resolve button alignment docs: update README Common Types: feat | fix | docs | refactor | test | perf Why Use Conventional Commits? ✅ Clear team communication ✅ Auto-generate changelogs ✅ Easy project navigation ✅ Industry-standard best practices Found it helpful? Share it with your team! Drop your thoughts in the comments! #Git #SoftwareDevelopment #CleanCode #BestPractices #TechArticle #Programming #DevCommunity #Coding #TechWriting #SoftwareEngineering
To view or add a comment, sign in
-
Commenting Out Code Is Not Version Control Your codebase has 200 lines of commented code "just in case." Delete them. Git remembers. Commented code is actually technical debt. We've all done this at some point: function calculateTotal(items) { return items.reduce((sum, item) => sum + item.price, 0); // Old implementation - keeping just in case // let total = 0; // for (let i = 0; i < items.length; i++) { // total += items[i].price; // } // return total; } "Just in case we need it later." You won't. Delete it. The Problem with Commented Code: ❌ It confuses new developers. "Should I use this? Is this the right way? Why are there two versions?" ❌ It makes code harder to read. You're scanning through 50 lines to find 10 that actually run. ❌ It rots. Commented code doesn't get updated. Six months later, it won't even work if you uncomment it. ❌ Nobody knows if it's safe to delete. "This has been here for 2 years. Someone must have kept it for a reason, right?" "But What If We Need It?" You have Git. Use it. Git is your time machine. Every deleted line is still there in history. Need to find old code? # Find every commit that added or removed a string git log -S "old function name" --source --all # See the full file from a specific commit git show <commit-hash>:path/to/file.js # Show the entire commit history of a file, even for deleted lines git log --all --full-history -- path/to/file.js If you really need it back, it's a 30-second search away. What to Delete: ✅ Old implementations - The new code works. Trust it. ✅ "Maybe we'll need this" - You won't. If you do, Git has it. ✅ Debugging code - console.log, test data, temporary fixes. ✅ Experiments that didn't work - Failed approaches don't belong in main. ✅ TODOs from 2 years ago - If it was important, it would be done. What you can keep: ✅ Explanations of non-obvious decisions (why this was done this way). ✅ Documentation comments (JSDoc, docstrings). Open your codebase right now. Search for // or /* or #. How many commented-out lines do you find? Delete 10 of them today. 🙂 You're welcome.
To view or add a comment, sign in
-
-
The last time I spoke about Git, I sparked a debate. 😅 This time, I’m not but let’s talk. This post is for those who are new and want to use Git and GitHub to do exciting things. 🚀 I find this topic fascinating because many entry-level devs high on vibe coding still wonder why Git is such a big deal. It often feels like we exaggerate the importance of Git, and even when beginners use it, their workflow usually stops at these three commands: $ git add . $ git commit -m "commit message" $ git push But let’s share some cool stuff. 😎 If you’ve always wanted to collaborate with AI-powered builders like #v0, #Bolt, or #Lovable, beyond just saying “build me a full-blown hotel booking web app,” then this will come in handy. Let’s start with some soft commands first. We already know that one button connects GitHub to your project and creates your repository. So what next? 👉 Get it on your laptop: $ git clone <remote-url> Now it’s on your system, and you’re coding away. But wait, it doesn’t update automatically on your laptop. That’s because you haven’t pulled the latest changes. 👉Then you Pull changes: $ git pull Now it’s synced! But you don’t want to keep doing pull, pull, pull forever, you want to get involved too. 👉 Create your own branch: $ git checkout -b my-edits Cool, right? 😎 Because sometimes, you might just want to change a single word… and then the AI decides to go wild. 😂 But that’s not all, there’s more to come. Here are some interesting commands you’ll encounter as you grow: $ git revert $ git fetch origin && git rebase origin/main $ git push -f $ git reset --hard HEAD~1 $ git cherry-pick <commit> $ git stash && git stash apply stash@{n} $ git bisect These commands make collaboration with AI-powered builders and agents feel like having a full dev team working alongside you. 🤖💻 Check out my featured section and subscribe to my newsletter. I’ll be writing an article that’ll help you manage your builds efficiently with AI-powered tools. And if you haven’t followed or connected with me yet Chibuike Nwafor… now’s the best time. #SoftwareEngineering #DevelopersCommunity #AI #GitAndGitHub
To view or add a comment, sign in
-
-
Here are 12 must-know Git commands with quick explanations and examples: • git init: Initializes a new Git repository in your current directory. • Example: $ git init • git add: Stages changes (files/directories) for the next commit. • Example: $ git add app.css • git commit: Records the staged changes with a commit message. • Example: $ git commit -m "Initial commit" • git push: Uploads your local changes to a remote repository (e.g., GitHub). • Example: $ git push origin main • git pull: Fetches and merges changes from the remote repository into your local branch. • Example: $ git pull origin main • git remote: Manages the remote repositories connected to your project. • Example: $ git remote add origin <url> • git branch: Lists, creates, or deletes branches. • Example: $ git branch feature-login • git fetch: Retrieves the latest data from the remote repo but doesn't integrate it into your working files (unlike git pull). • Example: $ git fetch origin • git checkout: Switches between branches or restores working tree files. • Example: $ git checkout feature-login • git merge: Combines the specified branch into your current branch. • Example: $ git merge feature-login • git status: Displays the state of your working directory and staging area. Essential for checking uncommitted changes! • Example: $ git status • git reset: Undoes changes. Resets the current branch to a specified commit. • Example: $ git reset --hard <commit-hash> Which Git command do you use the most? Share your favorite tip below! 👇 #Git #Developer #Coding #VersionControl #Programming #TechTips #SoftwareDevelopment #Backend #TechTips #Coding #DevCommunity #AdarshMurali
To view or add a comment, sign in
-
-
🚀 Quick Git Tip for Developers Ever been in the middle of building a new component when suddenly you’re asked to jump into another branch to fix a critical UI bug? You try to switch branches, but Git or VS Code blocks you: ❌ "Your local changes would be overwritten" Don’t panic and don’t commit half-finished code just to get around it. 👉 Meet your silent hero: git stash This saves all your uncommitted changes in a temporary safe spot without cluttering your commit history. Now you can freely: - Switch branches. - Pull updates. - Fix urgent issues. - Experiment safely. When you’re ready to return to your original work use : " git stash pop " and boom all your changes are back exactly as you left them! 💡 Pro tips: git stash list : see all your saved stashes git stash apply : restore without deleting the stash Stashes are branch-agnostic you can apply them anywhere. ✨ Keep your Git history clean, your PRs focused, and your workflow smooth. #FrontEnd #Angular #JavaScript #TypeScript #Git #WebDevelopment #DeveloperTips #VSCode #CleanCode #SoftwareEngineering #TechTips #AngularDev #CodeLife
To view or add a comment, sign in
-
Picture this: It’s 2 AM, you’re rushing to deploy a critical fix, and you accidentally commit code with a glaring syntax error. The CI pipeline fails, your team gets paged, and what should have been a quick fix turns into an hour-long debugging session. Sound familiar? This scenario plays out in development teams worldwide, but it doesn’t have to be your story. Enter Git pre-commit hooks — your automated quality control system that catches issues before they ever leave your local machine. https://lnkd.in/ep7hgnU4
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
-
𝐆𝐈𝐓 — 𝐓𝐇𝐄 𝐓𝐈𝐌𝐄 𝐌𝐀𝐂𝐇𝐈𝐍𝐄 𝐅𝐎𝐑 𝐃𝐄𝐕𝐄𝐋𝐎𝐏𝐄𝐑𝐒 🕰️🚀 A few years back, when I made my first coding blunder (and trust me, it was huge 😅), my senior looked at me and calmly said, > “Just roll back. Git will save you.” That day, I didn’t just learn a tool. I discovered a superpower — a personal time machine for developers. Think of your project like a movie set: 🎬 Workspace → It’s your shooting floor. Here you act, make changes, experiment, and sometimes… break things. 📝 Stage → Like a director shortlisting the best takes, you use git add to prepare only the scenes (files) you want to keep. 🎞️ Local Repository → Your backstage vault. Here your committed scenes (git commit) are stored safely — even if the set burns down (😅). 🌐 Remote Repository → The studio archive — whether it’s GitHub, GitLab or Bitbucket. Here, your work lives in the cloud, away from local disasters. --- Here’s how your daily Git storyline flows 👇 🔹 git add → Selecting the perfect takes. 🔹 git commit → Locking the scene in your vault. 🔹 git push → Sending it to the studio (remote repo). 🔹 git fetch → Checking what’s happening on other sets. 🔹 git pull → Bringing updates from the studio + merging with your work. 🔹 git merge → Blending your take with others — like joining multiple storylines. And the best part? Even if someone rewrites the plot, Git ensures no masterpiece is ever truly lost. --- 💡 Pro tip: git fetch = a sneak peek at what’s new. git pull = fetch + merge → bringing the new script into your story. Commits are like save points in a game. You can rewind, branch, or experiment without fear. --- 🚀 Why Git matters: It encourages collaboration without collision. It gives you the confidence to break things — because you can always roll back. It makes your project future-proof. Every git commit isn’t just a line of code. It’s a chapter in your project’s story. So next time you code, remember — 👉 You’re not just writing functions. 👉 You’re authoring history. #Git #VersionControl #GitHub #Developers #CodingLife #SoftwareEngineering #GitCommands #TechStory #Collaboration #Programming #DevOps
To view or add a comment, sign in
-
-
If you're a solo developer, consider this simple setup. 1. Use the package npm-run-all to run scripts locally in parallel. 2. Add Husky to connect common scripts in your app (format, lint, tests, build, type-check, unit tests, component tests) and run them on commit. 3. Commit directly to main — this triggers an automatic deployment to production. 4. Use pnpm - it's just really good :D. Being a solo dev these days doesn’t require a complex CI/CD setup. You can run all the basic checks locally to avoid context switching, and let Vercel, Netlify, or Cloudflare handle automatic deployments to production after each commit to main. This setup works perfectly with trunk-based development and feature flags. I use this approach for every new app I build. 1. Working on a feature that’s not finished yet? Add a feature flag, commit, and it auto-deploys to production. 2. When the feature is ready, commit again — it auto-deploys, and the feature becomes visible. 3. On each commit, tests and checks run automatically (usually 30–45 seconds for larger projects). No context switching — everything happens locally on my machine. 4. This setup can be tricky with E2E tests (you might need Docker to ensure consistent results). Still totally doable — just requires slightly different scripts and setup. 5. Husky connects to the commit hook and runs checks. I also added another hook to enforce conventional commits. This setup is small, fast, and simple — no unnecessary branches or merges. It’s perfect for solo developers, and it even works for small teams (1–2 devs). Just keep in mind: anyone (even you 😄) can bypass it if needed. You can adjust it however you prefer, but here’s my current setup: 1. Format + Lint → runs via lint-staged, after "git add ." command. 2. Type-check → runs on commit message command, together with commitlint for commit message validation. 3. Build + Tests → run on the pre-push phase. Here how it looks in practice: ``` git add . # Runs Format + Lint via lint-staged only changed files git commit -m 'feat(app): my feature name' # Runs TypeCheck + Conventional Commit check git push # Runs units, build, component tests (all parallel) ``` This setup keeps development fast, iterative, and atomic, while still preventing most regressions. If you're interested in, I can craft nice/short article + add repo guide if you want.
To view or add a comment, sign in
-
-
Ever made a commit and instantly spotted a typo in the message? That sinking feeling of knowing you have to wrestle with git rebase can be frustrating. Editing Git history is powerful, but it's often complex and risky. That's the problem I wanted to solve with my new open-source project, Git Time Machine Plus. It's a VS Code extension that gives you a safe and visual way to edit your recent commits. My goal was to provide an intuitive interface for common tasks without forcing you to memorize complex commands. It includes: - Safe editing with remote verification (it checks if commits are pushed) A visual date/time picker - Bulk editing and one-click undo - Automatic backup branches for peace of mind - I built it using TypeScript and Tailwind CSS on top of the VS Code Extension API. It's free and available on the VS Code Marketplace and Open VSX Registry and the source code is open if you'd like to explore or contribute. 🔗 GitHub Repo: https://lnkd.in/gBBzK3YP 📦 VS Code Marketplace:https://lnkd.in/gieygn9j 🧩 Open VSX:https://lnkd.in/gbHJf-mg Would love your feedback if you try it out! #VSCode #DeveloperTools #Git #TypeScript #SoftwareDevelopment #Programming #WebDev #DevTools #Productivity #GitWorkflow
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