ptpdlc
ptpdlc

Reputation: 2613

Git - efficient way to add files in commandline

I prefer using my Git commandline, feels like I know what I am doing (or if not, I can only blame myself...).

Still, it always feels like git add-ing files is the least efficient thing to do.

I do not like the -a option, especially when I really do not mean to add all files. I do like the -i feature that allows me to add all files just by typing numbers (or just add snippets).

But just adding let's say four files feels like a pain - have to git status, then copy/paste etc...

Ayn tips? better workflow?

Upvotes: 1

Views: 162

Answers (1)

kuskmen
kuskmen

Reputation: 3775

You can add files using globs pattern this is extension of shell but not the git itself.

For example if you have

src/files-I-want-to-commit/file1
src/files-I-want-to-commit/file2
src/files-I-want-to-commit/file3
src/files-I-Dont-want-to-commit/file

You can simply do

git add src/files-I-want-to-commit/

If you have:

src/files-I-want-to-commit/commit_file1
src/files-I-want-to-commit/oh-I-dont-want-to-commit-that
src/files-I-want-to-commit/and-that

You can then do:

git add src/files-I-want-to-commit/commit_*

And so on.

Upvotes: 2

Related Questions