4

I have a variety of scattered paths and files defined in my .gitignore files. One of my typical workflow patterns is to navigate to a path, then do git add * to stage all changes under that path. When I do this, however, I sometimes get a warning, "The following paths are ignored by one of your .gitignore files:...".

The paths are intended to be ignored. Is there a way to either A) suppress this warning when running git add *, or B) use a different git command that does not trigger it, but has the same behavior and is similarly concise?

3
  • 2
    Never saw this before. But I always use git add . (dot instead of *).
    – akop
    Commented Jun 6, 2019 at 21:41
  • 2
    Do you still get a warning with git add .?
    – melpomene
    Commented Jun 6, 2019 at 21:42
  • 1
    @melpomene The warning is not printed when using . and I've included that in my answer. Thank you and @user6537157 for reminding me of this obvious solution.
    – Matthew
    Commented Jun 7, 2019 at 0:28

1 Answer 1

7

The simplest and most elegant solution to your problem (courtesy of the comment section) is to use . instead of * to index all of your files if and only if it fits your needs. Read here to understand the subtle difference between using these two symbols in the current context.

git add . 

Another thing you could do is direct the output of the command to a local log file of your choosing. This way the operation will completely silently in the console but the output will be logged inside your designated log file so you don't miss out on important stuff:

git add * &> output.log

You could also run the command completely silently without any console input by appending &> /dev/null, however I would not recommend this as it will block the command from giving you any console output at all so you have to be careful when using this as you will not see if any errors or serious warnings occurred.*

git add * &> /dev/null
4
  • Another thing to try would be git add '*' (i.e. escaping *). I'm not sure what exactly it would do.
    – melpomene
    Commented Jun 7, 2019 at 0:31
  • @melpomene It also avoids the warning but I am not sure if it actually performs the add operation. I will check that out tomorrow.
    – Matthew
    Commented Jun 7, 2019 at 0:32
  • put the . solution at the top and I'll accept your answer. routing output to /dev/null should not be encouraged...
    – MooseBoys
    Commented Jun 10, 2019 at 19:59
  • @MooseBoys I agree with you and I've moved the preferred solution to the top of the answer.
    – Matthew
    Commented Jun 10, 2019 at 20:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.