-
-
Notifications
You must be signed in to change notification settings - Fork 954
To exclude files in repo.git.add() #1507
-
Hi,
How to exclude files in repo.git.add() ? because --all only worked for me , not -- :!
Or maybe I could do it wrong. If possible , kindly share a sample line of code for excluding
Thank you.
Beta Was this translation helpful? Give feedback.
All reactions
To answer the question, there should be clarity about what was tried exactly (with python code), along with the result of that code, and the expected result.
Generally with repo.git.add(...)
all possible invocation of the sub-command are possible, if necessary by passing args directly with repo.git.add('--arg1', '--arg2', 'positional1', 'positional2')
. More about direct git
invocations can be found in the docs.
Replies: 1 comment 3 replies
-
To answer the question, there should be clarity about what was tried exactly (with python code), along with the result of that code, and the expected result.
Generally with repo.git.add(...)
all possible invocation of the sub-command are possible, if necessary by passing args directly with repo.git.add('--arg1', '--arg2', 'positional1', 'positional2')
. More about direct git
invocations can be found in the docs.
Beta Was this translation helpful? Give feedback.
All reactions
-
Hey Sebastian , Thanks for your reply. Here's what I tried :
git.add("--all", "-- ':!ml_subcats.zip'")
Error thrown as below:
Arguments: (GitCommandError(['git', 'add', '--all', "-- :!ml_subcats.zip"], 129, b"error: unknown option ` ':!ml_subcats.zip''\nusage: git add [<options>] [--] <pathspec>...\n\n -n, --dry-run dry run\n -v, --verbose be verbose\n\n -i, --interactive interactive picking\n -p, --patch select hunks interactively\n -e, --edit edit current diff and apply\n -f, --force allow adding otherwise ignored files\n -u, --update update tracked files\n --renormalize renormalize EOL of tracked files (implies -u)\n -N, --intent-to-add record only the fact that the path will be added later\n -A, --all add changes from all tracked and untracked files\n --ignore-removal ignore paths removed in the working tree (same as --no-all)\n --refresh don't add, only refresh the index\n --ignore-errors just skip files which cannot be added because of errors\n --ignore-missing check if - even missing - files are ignored in dry run\n --chmod (+|-)x override the executable bit of the listed files\n --pathspec-from-file <file>\n read pathspec from file\n --pathspec-file-nul with --pathspec-from-file, pathspec elements are separated with NUL character\n", b''),)
Beta Was this translation helpful? Give feedback.
All reactions
-
You probably mean git.add("--all", "--", ':!ml_subcats.zip')
.
Beta Was this translation helpful? Give feedback.
All reactions
-
Thank you Sebastian for suggesting this. But just a few minutes back I tried another option like this , and it worked (instead of exclamatory, I used carat symbol). Thanks for your support.
git.add("--all", ':^*.zip')
Beta Was this translation helpful? Give feedback.