Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

To exclude files in repo.git.add() #1507

Answered by Byron
amrs-saama asked this question in Q&A
Discussion options

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.

You must be logged in to vote

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

Comment options

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.

You must be logged in to vote
3 replies
Comment options

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''),)
Comment options

Byron Nov 1, 2022
Maintainer

You probably mean git.add("--all", "--", ':!ml_subcats.zip').

Comment options

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')

Answer selected by amrs-saama
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants

AltStyle によって変換されたページ (->オリジナル) /