One tiny asterisk (*) taught me a big lesson about how Git and shell work. I recently ran into an issue while working with Git. I had a bunch of Markdown files spread across multiple nested folders, and I wanted to stage them all at once. So I ran git add *.md But only the .md files in my current directory were added. Nothing from the nested folders showed up. I was wondering why Git wasn’t doing what I expected. Here is what happened: the * wildcard is expanded by the shell, not by Git. So the shell only looked for matches in the current directory. The fix is to use git add '**/*.md' By wrapping **/*.md in quotes, you’re telling the shell not to expand the pattern. So Git receives the literal string **/*.md. Git then uses it's own globbing which handles recursive paths. A small issue, but it reminded me how much happens before a command even reaches Git & the concept of Git globbing. I wrote a short blog post with more details (link in the comments). Did you ever run into something like this with Git or your shell? #GitTips #BashTips #DevOps #CLI #DevTips
Sidharth R’s Post
More Relevant Posts
-
Flow: git add We run git add all the time, but under the hood, it’s doing a lot more than most people realize. When you stage a file like hello.txt, three major things happen 1️⃣ Hashing & Blob Creation. Git reads your file byte by byte and prepends a small header: blob <size>\0 It then hashes that data, producing a unique SHA-1 fingerprint (like abcd1234ef567890...). That compressed version is stored inside: .git/objects/ab/cd1234ef567890... This is your blob object. It holds your file’s actual content. 2️⃣ Updating the Index. Git updates its internal tracker, the index (also called the staging area). It records which blob corresponds to which file: hello.txt → abcd1234 (blob) This map lives in .git/index, and it’s how Git knows what’s ready to commit. 3️⃣ Marking Ready for Commit. No branches change yet. No commits yet. You’ve just told Git: “Keep this exact version of hello.txt ready for my next commit.” Explore the Flow. You can zoom, pan, and trace how hello.txt moves through Git’s internals right here: https://lnkd.in/gXVpWgQq That’s the real story behind git add. It’s not just “adding a file”; it’s Git quietly building its internal universe. Next up in the Flow series: git commit the moment everything gets locked into history. #GitFlow #VersionControl #CodingInsights #GitAddExplained #DeveloperLife #TechEducation #SoftwareDevelopment #GitMagic #CommitmentToCode #LearnGit
To view or add a comment, sign in
-
-
Git Like a Pro: The Ultimate Command Cheat Sheet Ever got stuck fixing merge conflicts or juggling multiple branches? Here’s your one-stop Git refresher to get back on track fast. ==> 𝐃𝐚𝐢𝐥𝐲 𝐄𝐬𝐬𝐞𝐧𝐭𝐢𝐚𝐥𝐬 git status # Check what changed git add . # Stage all files git commit -m "msg" # Commit with message git push origin main # Push to remote ==> 𝐒𝐦𝐚𝐫𝐭 𝐁𝐫𝐚𝐧𝐜𝐡𝐢𝐧𝐠 git branch dev # Create a branch git checkout dev # Switch to it git checkout -b feature/ui # Create & switch together git merge dev # Merge into current branch ==> 𝐔𝐧𝐝𝐨 & 𝐅𝐢𝐱 𝐌𝐢𝐬𝐭𝐚𝐤𝐞𝐬 git restore . # Undo unstaged changes git reset --hard HEAD~1 # Remove last commit git revert <commit_hash> # Revert safely ==> 𝐒𝐲𝐧𝐜 & 𝐂𝐥𝐞𝐚𝐧 𝐔𝐩 git fetch --all # Fetch from all remotes git pull origin main # Sync with latest git prune # Clean up branches Keep your commits small, meaningful, and consistent. #GitTips #DevLife #CodeSmarter #VersionControl #GitCheatSheet #DevEssentials
To view or add a comment, sign in
-
-
## 🔥 Day 21/50: Stop the Git Overhead! 🔥 You're on-call. An alert fires. You find the 1-line fix. Now you have to type `git add .`, then `git checkout -b fix-the-thing`, then `git commit -m "fix: the thing"`. It's 3-4 commands for a 10-second change. That's way too much (for me, personally). And yes, you should use a fresh branch for each Merge/Pull Request! Why not use a shortcut? 🛠️ This is one of my all-time favorite timesavers, and it lives right in my `.zshrc` file. It's a function that bundles all those steps into one command. I just type `gbc` followed by my branch name, formatted for *Conventional Commits*. For example, if I run: `gbc fix-add-missing-value` This single command automatically does all of this for me: 1. Runs `git add .` 2. Runs `git checkout -b "fix-add-missing-value"` 3. Runs `git commit -m "fix: add missing value"` (It simply formats the commit message!) Works for all kinds of commits: `gbc docs-specify-how-vcluster-works` creates a commit `docs: specify how vcluster works`. It's simple, but it saved me a lot of typing while being on-call. And typing = time. ✨ The benefits: ➡️ It's FAST: It turns a 4-step chore into a 1-step command. ➡️ Enforces Clean History: It's the laziest way to enforce Conventional Commits. ➡️ Perfect for On-Call: When speed and focus matter, this gets you in and out. After it's done, I just type `gp` (my alias for `git push`) and my fix is on its way. What's your #1 time-saving shell function or alias that you can't live without anymore? PS: Want to save yet *another* click? Set your push alias to `gp="git push -o merge_request.create"`. This tells GitLab (or GitHub) to automatically create the merge request for you. Saves you one click!
To view or add a comment, sign in
-
-
Git has hundreds of commands, but these five will transform how you work. Clean up messy histories, recover lost work, and debug faster. Stop committing "WIP" and start using Git like a pro. Which Git command do you wish you'd learned sooner? 🔁 Repost if this was helpful!
To view or add a comment, sign in
-
🚀 Boost Your Git Skills! If you’ve ever struggled to remember Git commands or felt lost in branches, merges, and commits, this Git Commands Cheatsheet is here to save the day! 🛠️ From basic commands like git init, git clone, and git commit to advanced operations like rebase, stash - this cheatsheet has it all in one easy-to-use reference. Whether you’re a beginner trying to get started or a seasoned developer looking for a quick refresher, this guide will make your Git workflow faster, smoother, and more efficient. 💻✨ 💡 Tip: Repost it, Save it, print it, or pin it—it’s a small step that can save hours of confusion later! #Git #GitCommands #DeveloperTools #Coding #MERNStack #SoftwareDevelopment #Productivity #CheatSheet
To view or add a comment, sign in
-
-
Git Beyond Basics — Day 6 Ever wondered what really happens inside your .git folder? Today, I explored how Git stores commits, trees, and blobs — and it’s mind-blowing how everything connects like a linked list! 🔗 Here’s what I discovered: ->Every commit is an object that stores metadata (author, parent, message). ->Each commit points to a tree object, which represents a snapshot of your files. ->Each file in that tree is a blob object, holding the actual file content. ->And yes — you can peek inside them using: git cat-file -p <hash> Git doesn’t just track changes, it tracks snapshots of your entire project history. Learning Git beyond commands really changes how you see version control — it’s not magic, it’s logic ✨ #Git #VersionControl #Learningjourney #day6 #GitBeyondBasics #insidegit #gitrepo #DevelopersJourney
To view or add a comment, sign in
-
How to Make Git “Pretend It Didn’t See Anything” 👀 Have you ever needed to change a file only on your local machine, but couldn’t risk committing it by mistake? That was me a while ago. I couldn’t add it to .gitignore, and I definitely didn’t want to play with fire on the main branch. Then I found this little trick, one of those hidden Git gems that makes you wonder “how did I not know this before?” Think of Git as that one coworker who writes down every single thing you do. But sometimes, you just want to move a few things on your desk and keep it to yourself. That’s when you tell Git: “Pretend you didn’t see anything.” Here’s the command: git update-index --assume-unchanged src/environment.js After that, git will ignore local changes temporarily. If you run git status, the file won’t even show up as modified. And when you want to make git pay attention again: git update-index --no-assume-unchanged src/environment.js No .gitignore mess. No accidental commits. No panic before pushing your code. What’s another hidden git command you’ve found useful lately? #git #Frontend #DevTips #SoftwareEngineering
To view or add a comment, sign in
-
-
🧠 Git Snippet Review: Clean Code Practices Ever reviewed a Git PR and felt like the code works… but doesn’t feel right? Here’s what I look for beyond functionality 👇 🔹 Meaningful variable names ❌ temp, data1 ✅ userProfile, orderTotal 🔹 Small, focused methods If your method does 5 things, it’s doing too much. 🔹 Avoid magic numbers & hardcoded values Use constants. Make your code readable for future you. 🔹 Consistent formatting & indentation Clean code isn’t just logic it’s visual clarity. 🔹 Clear commit messages fix bug ≠ helpful ✅ Fix null pointer in UserService when profile is missing 📌 Clean code isn’t perfection it’s empathy for the next developer (which might be you). 💬 What’s your #1 clean code rule during Git reviews? Drop it below 👇 #GitReview #CleanCode #BackendEngineering #JavaDeveloper #CodeQuality #LinkedInLearning #DevTips
To view or add a comment, sign in
-
🚀 GIT Series — Part 3: Understanding Git Workflow Now that Git is set up, let’s look at how developers actually use it daily. Git works in three main areas: 1️⃣ Working Directory → where you edit your files 2️⃣ Staging Area (Index) → where you prepare files to be committed 3️⃣ Repository (Local) → where committed changes are stored 🔁 Basic Workflow: Make changes to your files Stage your changes: git add <filename> # or git add . to add all Commit your changes: git commit -m "Added new feature" Push to GitHub: git push origin main 🧩 Helpful Commands: git status → Check modified/untracked files git diff → See changes before committing git log → View commit history 🧠 Pro Tip: Keep commits small and focused. Example: ✅ “Fixed typo in README” ❌ “Updated many random things” Good commit messages = easier debugging + better collaboration. #GitWorkflow #CodingBestPractices #VSCode #SoftwareDevelopment #GitTips
To view or add a comment, sign in
-
Lock yourself in a room and master this Git command (you'll thank me later): 1. `git push --force-with-lease` This command contains the biggest secret to safe Git pushing. Lessons: • Prevent accidental overwrites • Ensure your local branch is up-to-date before pushing We’ve all been there—accidentally using `git push --force`, overwriting someone else's work, and causing chaos. But did you know there’s a safer alternative? Instead of: ```sh git push --force ``` Use: ```sh git push --force-with-lease ``` Why? `--force-with-lease` ensures that your local branch is up-to-date before force-pushing. It prevents accidental overwrites if someone else has pushed changes while you were working. How It Works: - If no one else has pushed new commits, your force-push succeeds. - If someone else has pushed, Git stops you from overwriting their work. This small change prevents mistakes and keeps your team’s workflow smooth. Who else has used this in their workflow? Share your experience below. #GitTips #GitLab #GitHub #SoftwareEngineering #DevOps #FullStackDevelopment
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
Here is the blog post: https://nerdsid.com/posts/git/why-git-add-wildcard-won-t-stage-your-nested-files-and-how-to-fix-it/