Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3361744
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:11:22+00:00 2026-05-18T03:11:22+00:00

When using git add with a file pattern it only adds recursively the untracked

  • 0

When using “git add” with a file pattern it only adds recursively the untracked files, and ignores the changed ones unless they are in the current folder.

Example:

$ git status
# On branch master
# Changed but not updated:
#    (use "git add <file>..." to update what will be committed)
#    (use "git checkout -- <file>..." to discard changes in working directory)
#
#       modified:    level1/test1.txt
#       modified:    level1/level2/test1.txt
#
# Untracked files:
#   (use "git add <file>..." to incldude in what will be committed)
# 
#       level1/test2.txt
#       level1/level2/test2.txt
no changes added to commit (use "git add" and/or "git commit -a")
$ git add level1\*.txt
$ git status
# On branch master
# Changes to be committed:
#       new file:   level1/level2/test2.txt
#       new file:   level1/test2.txt
#
# Changed but not updated:
#       modified:   level1/level2/test1.txt
#       modified:   level1/test1.txt
#

After I execute git add level1\*.txt, the untracked (test2.txt) files are added, but not the modified (test1.txt) files. I’ve tried with the -u option, escaping and not escaping the asterisk, etc. but nothing seems to simply be able to add ALL files matching a pattern whether they are tracked or not.

Of course in this example I could just add all the files with -A, but keep in mind this is just for the purpose of this question, in reality there will be more files and I would not want to add them all, and the hierarchy is a few folders deeper. The only way for me to add the tracked files is referring to the directing or writing the whole pattern except for the file name like this: git add level1**.txt OR git add level1/level2/*.txt.

In the git add documentation: here it says that the file pattern is supposed to work recursively and doesn’t say anything about tracked or untracked files and it even gives and example.

I’m using msysgit but I’ve tested this on Windows and Linux just in case.

I just want to know. Am I interpreting the documentation correctly (because I think based on the docs it should work) or is this how it is supposed to work? It just doesn’t make sense to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T03:11:23+00:00Added an answer on May 18, 2026 at 3:11 am

    All right, there might as well be an answer on this question.

    No, that doesn’t seem to be the right behavior at all. git add <filepattern> should be equivalent to git add file1 file2..., where those are the files matched by the pattern – and that’s not what happens here.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I mistakenly added files to Git using the command: git add myfile.txt I have
I am using git on a project, that generates lots of data-files (simulation-results). I
I've been using git for some time now on Windows (with msysGit) and I
I've been using Git on Linux for about a year, and everything works fine.
I recently started using Git as my version control system for some Cocoa projects
I have been using git to keep two copies of my project in sync,
I'm using git for a PHP project, I think it's really handy. There is
I've been using Git now for a couple of months on a project with
I am using git for windows to manage a local project. I have two
Please provide tips for effectively using git with svn. What are your best practices?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.