Git - efficient way to add files in commandline

2019-08-08 08:28发布

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?

1条回答
Viruses.
2楼-- · 2019-08-08 08:35

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.

查看更多
登录 后发表回答