Sidharth R’s Post

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

  • A git command is first interpreted by shell (like bash), then it's passed on to Git

To view or add a comment, sign in

Explore content categories