Stage file by its file name, regardless of directory--Git

Viewed 6464

I have very nested directories in a project, and I'm a lazy programmer.

Let's say I have a file name EventEditor.foo I want to stage my file regardless of whether it's in the root directory or ./src/holy/sweet/mother/of/baby/raptor/jesus/this/is/a/long/hiearchy/EventEditor.foo

My goal would be to be all, "Yo Git, add EventEditor" and bam. It stages it with me only having to type something like git add *EventEdi*. Is this possible? Or am I day dreaming?

8 Answers

I use a combination of the following scripts to do what you ask.

I have this aliased to gga:

git ls-files -m -o --exclude-standard | grep $* | xargs -r git add

usage:

gga raptor # stages everything in raptor directory
gga Event #stages all files with Event in the name

you get the idea.

If I have to be more specific about things (because grepping isn't specific enough), I just use

git ls-files | grep

Then I just copy and paste the full path of the file into git add.

Related