3

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?

MooseBoys
  • 6,641
  • 1
  • 19
  • 43

1 Answers1

6

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
Matthew
  • 1,905
  • 3
  • 19
  • 26
  • Another thing to try would be `git add '*'` (i.e. escaping `*`). I'm not sure what exactly it would do. – melpomene Jun 07 '19 at 00: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 Jun 07 '19 at 00:32
  • put the `.` solution at the top and I'll accept your answer. routing output to `/dev/null` should not be encouraged... – MooseBoys Jun 10 '19 at 19:59
  • @MooseBoys I agree with you and I've moved the preferred solution to the top of the answer. – Matthew Jun 10 '19 at 20:09